在壳中期待

时间:2015-05-03 09:59:04

标签: shell expect

我正在使用期望代码将文件scp到远程位置。以下是代码:

#!/usr/bin/expect
set DATE [clock format [clock seconds] -format {%Y_%m_%d}]
set VAR /LDAPBackup/binbak/Meta1/binbak_$DATE.tar
spawn scp $VAR netscape@AOAAPLD00051.nbcuni.ge.com:/home/netscape/scripts/file_scp
expect "Password:"
send "*$stg\r"
expect eof
exit

我遇到的错误如下: -

spawn scp /LDAPBackup/binbak/Meta1/binbak_2015_05_03.tar netscape@AOAAPLD00051.nbcuni.ge.com:/home/netscape/scripts/file_scp
`Password: can't read "stg": no such variable while executing
"send "*$stg\r""
(file "./scp_dev" line 6)`

任何人都可以告诉你这样做的正确方法。

0 个答案:

没有答案