[英]Unable to mput all the files through sftp in the remote server using expect
我想mput
出现在目录中的所有文件: /Test/XML/
成的帮助下远程SFTP服务器expect
效用。
我在/ Test / XML /目录中大约有320个文件。
每个文件的大小约为0.1 MB。
没有观察到错误。
这是我的代码:
cd /Test/XML/
/usr/bin/expect <<EOF
spawn /usr/bin/sftp ${user_name}@${HOSTNAME}
expect "password:"
send "${passwd}\r"
expect "sftp>"
send "cd /test\r"
expect "sftp>"
send "mkdir XML\r"
expect "sftp>"
send "cd /test/XML\r"
expect "sftp>"
send "mput *\r"
expect "sftp>"
send "bye\r"
EOF
但是这里的问题是, mput *
仅传输4个文件,而不是传输所有320个文件。 不确定,为什么它不能传输远程服务器中的所有320个文件。
任何帮助都是最欢迎的。
感谢@ThiruShetty使用的提示set timeout -1
的expect
效用。
实际上,我有很多文件(〜320-350)要传输(sftp)到远程服务器。 随着正常执行sftp
使用expect
效用,它能够传递只有少数文件,不是所有的人,我想要的。
在expect
插入set timeout -1
后,解决了超时问题。
这是最终代码:
cd /Test/XML/
/usr/bin/expect <<EOF
set timeout -1
spawn /usr/bin/sftp ${user_name}@${HOSTNAME}
expect "password:"
send "${passwd}\r"
expect "sftp>"
send "cd /test\r"
expect "sftp>"
send "mkdir XML\r"
expect "sftp>"
send "cd /test/XML\r"
expect "sftp>"
send "mput *\r"
expect "sftp>"
send "bye\r"
EOF
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.