我在一个文件夹中有一堆文件要移动到ftp服务器的新文件夹中。 我可以使用以下代码登录到ftp服务器,但在登录后尝试创建并将文件移动到ftp服务器时出现错误。
这里$ Nelement是ftp服务器IP $ protocol是ftp
#!/bin/sh
cat $ftpFile | while read LINE
do
user=`echo $LINE | awk -F":" '{print $1}'`
pass=`echo $LINE | awk -F":" '{print $2}'`
protocol=`echo $LINE | awk -F":" '{print $3}'`
Nelement=`echo $LINE | awk -F":" '{print $4}'`
if [ "$protocol" = "ftp" ]; then
`$protocol -n $Nelement <<EOS
quote USER $user
quote PASS $pass
mkdir -p $dir
cd $dir
mput $newFileName
bye
EOS`
else
`$protocol $user@$Nelement <<EOS
bye
EOS`
fi
done
我收到的错误是
+ '[' ftp = ftp ']'
sc.sh: line 38: warning: here-document at line 31 delimited by end-of-file
(wanted `EOS')
+ Create directory operation failed. Failed to change directory. mput
'testfile.txt?' '?Invalid' command
sc.sh: line 31: Create: command not found