0

这是一个需要在 Solaris 上运行的 bash 脚本,它从 dirlocal 获取文件,复制到 backupdir 并通过 SFTP 发送它们。问题是它只发送 4-5MB 的数据,然后它挂起(我认为在 mput 的某个地方),而手动一切正常。真的不知道该怎么办...

#!/bin/bash
export LD_LIBRARY_PATH=".:../tool/bin:$LD_LIBRARY_PATH"
dirlocal=</export/home/somedir>
dirlocal_backup=</export/home/somebackupdir>
filename=*
if [ ! -e ${dirlocal}/${filename} ]; then
exit
fi
hostname=<some_ip_address>
username=ftp
password=FTP
remotedir=<somedir>
cd ${dirlocal}
cp * ${dirlocal_backup}
../tool/bin/expect -f - <<EOFEXPECT1 

set timeout 10
spawn -nottycopy -nottyinit sftp ${username}@${hostname}
expect {
     (yes/no) {send yes\r ; exp_continue }
     "*assword" {send ${password}\r ; exp_continue }
    }

expect -timeout 10 sftp { }
send "cd ${remotedir}\r";
expect -timeout 10 sftp { }
send "mput ${filename}\r";
expect -timeout -1 sftp {send "bye\r" }

#send "exit\r"
expect eof
EOFEXPECT1
if [ $? -eq 0 ]
then
rm ${filename} > /dev/null 2>&1
else
echo "something"
fi
4

1 回答 1

0

由于将评论标记为答案的功能请求仍然被拒绝,因此我在此处复制上述解决方案。

终于成功了。编辑的期望语句是线索。感谢帮助!来自俄罗斯的问候!– 用户2107698

于 2013-08-30T08:42:35.167 回答