我正在尝试将文件从 UNIX 服务器 FTP 到 Windows 服务器;在当前的情景中,
如果我的目标目录不存在,那么它会将文件通过 FTP 传输到默认目录。
我对这种情况的解决方法是检查目录是否存在,然后才 FTP 文件。只有我不知道如何实现。心理急救和建议。
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