如何在expect脚本中使用bash变量

时间:2016-04-20 14:42:31

标签: expect

我正在尝试使用expect执行基本操作:

#!/usr/bin/expect -f

# define location variable; will be numeric eg 1234321
v_dir=$(cat /tmp/patch.txt)

spawn sftp micky.mouse@company.com@server.company.com 
expect "password :"
send "Chu6!0ck\r"
expect "patch"
send "cd $v_dir\r"
interact

基本上,我正在尝试自动从远程补丁服务器获取补丁。修补程序编号来自调用脚本 - 现在我需要expect来读取该变量并cd来读取它。

1 个答案:

答案 0 :(得分:1)

简短的回答是在Expect程序中使用Expect语法。

set v_dir [exec cat /tmp/patch.txt]
相关问题