我在Linux上运行了一个FTP脚本,它正在失败。下面是脚本:
/usr/bin/ftp -v -i -n my.ftp.server << cmd
user ftpuser password
binary
ls
<some other commands here>
quit cmd它返回一个错误:
421 Service not available, remote server has closed connection
Not connected.奇怪的是,如果我在命令行/usr/bin/ftp my.ftp.server中输入了这个命令,它会询问用户名和密码,在我提供它们之后,我就可以连接了!
在ftp>中,我输入ls,我可以看到来自FTP服务器的文件。我的剧本怎么了?
而且,我没有putty访问FTP服务器的权限,所以我无法从那里看到日志。有什么想法吗?
谢谢!
发布于 2014-10-23 10:41:40
下面是一个正确的ftp脚本的示例。
#!/bin/sh
HOST='ftp.server.com'
USER='user'
PASSWD='pw'
FILE='file.txt' #sample file to upload
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE #sample command
#some other commands here
quit
END_SCRIPT
exit 0https://stackoverflow.com/questions/26525327
复制相似问题