【发布时间】:2016-07-27 21:20:04
【问题描述】:
我希望获得帮助以解决我的预期脚本问题。
当我在我的 linux 终端上使用命令“env”时,我可以看到 $INFO_HME 为 /app/informatica/etldev/9.1/server。
但我无法在我的期望脚本中使用$INFO_HME 它并出现错误。我的脚本如下所示。
我认为,$INFO_HME 将在 lcd 命令中替换为 /app/informatica/etldev/9.1/server。
#!/usr/bin/expect
spawn /usr/bin/sftp <ID_Here>@<Host_Here>
expect "password:"
send "<Password_Here>\n"
expect "sftp>"
send "lcd $INFO_HME/infa_shared/SrcFiles\n"
expect "sftp>"
send "cd \"/Source/client\"\n"
expect "sftp>"
send "get file.csv\n";
expect "sftp>"
send "quit\n"
错误信息:
sftp> can't read "INFO_HME": no such variable
while executing
"send "lcd $INFA_HOME/infa_shared/SrcFiles\n""
(file "Scr_Webcore_SFTP.sh" line 7)
非常感谢任何帮助解决此问题。
【问题讨论】:
-
您能否交叉检查这个错误 - 根据您的脚本发送“lcd $INFO_HME/infa_shared/SrcFiles\n”,我认为正确的变量应该是 $INFA_HOME。这是 informatica 环境变量,如果您已启动并运行 informatica,则必须进行设置。您可以看到的变量可能有些错误。
-
我已经检查过了。没有问题。使用以下方法解决了问题
标签: expect