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



我正在尝试使用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!0ckr"
expect "patch"
send "cd $v_dirr"
interact

基本上,我正在尝试从远程补丁服务器自动获取补丁。补丁号是从一个调用脚本中派生出来的——现在我需要expect来读取该变量,并需要cd

简单的答案是在Expect程序中使用Expect语法。

set v_dir [exec cat /tmp/patch.txt]

最新更新