【发布时间】:2013-05-26 09:54:51
【问题描述】:
我目前正在尝试使用带有 shell 脚本和期望包的 scp 命令自动执行文件传输。根据我所看到的,我似乎应该有
#!/usr/bin/expect -f
但是当我这样做时,我仍然得到错误:
DirectoryChange.sh: line 33: spawn: command not found
couldn't read file "*Password:*": no such file or directory
DirectoryChange.sh: line 35: send: command not found
DirectoryChange.sh: line 36: interact: command not found
我的代码是这样工作的:
#!/usr/bin/expect -f
repository=$PWD"/subdirectory/"
set pass "***********"
cd $repository
spawn scp -r user@host:/copyDirectory/ .
expect "*Password:*"
send "${pass}\r";
interact
【问题讨论】: