gpt4 book ai didi

windows - 从UNIX到Windows的FTP时如何检查远程服务器上目录的存在

转载 作者:可可西里 更新时间:2023-11-01 10:48:45 29 4
gpt4 key购买 nike

我正在尝试将文件从unix服务器ftp到windows服务器;在当前的senario中,
如果我的目标目录不存在,那么它是ftp文件到默认目录。
我的解决办法是检查目录是否存在,然后才ftp文件。只有我不知道如何实现同样的目标。pfa和建议。

srcpath=/home/fcadmin/Repository_ftp_test/venx

CS=/FCreportsrepository/Host
SCR_PATH=/home/fcadmin/Repository_ftp_test/venx
dpcpath=/fchostrjs/fcprdapp/dpcreports
logpath=/fchostrjs/fcprdapp/dpclog


for j in `cat venx.txt`
do

ftp -i -n <<EOF>ftp_me.log
open 10.226.14.102
user ftpuser abc!123
binary on
prompt
cd $CS
lcd $srcpath
if[<Directory Exists>];
then echo "Directory exists";
mput $j;
else
echo "Specified Directory doesnt Exist">>ftp_me.log;
exit;
fi
EOF

EXITFTP=$?
if test $EXITFTP -ne 0;
then echo "$D ERROR FTP" >> $LOG;
exit ;
fi

if (grep "^Not connected." ftp_me.log); then echo "$D ERROR FTP CONNECT" >> $LOG; fi
if (grep "No such file" ftp_me.log); then echo "$D ERROR FTP NO SUCH FILE" >> $LOG; fi
if (grep "access denied" ftp_me.log); then echo "$D ERROR FTP ACCESS DENIED" >> $LOG; fi
if (grep "^Please login" ftp_me.log); then echo "$D ERROR FTP LOGIN" >> $LOG; fi

done

最佳答案

在这种情况下,您必须使用2个ftp脚本,因为ftp不是一种允许进行此类检查的脚本语言。
登录后用dir命令在ftp中编写一个脚本。
目录/文件
一旦有了输出,就验证上面脚本的输出,并基于此确定第二个ftp脚本的目标目录。

关于windows - 从UNIX到Windows的FTP时如何检查远程服务器上目录的存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13267308/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com