我有一個名爲test.sh
的腳本。通過shell函數調用函數參數:在shell腳本中調用
其中包含的功能,
APPFE_Routes()
{
set filename [lindex $argv 0]
expect -c '
spawn ssh [email protected]
expect "Password: "
send "[email protected]\r"
expect "~]$"
send "su\r"
expect "Password: "
send "500tps\r"
expect "]#"
send "put ifconfig grep -i $filename\r"
expect -re "]#"
send "exit\r"
'
}
我打電話下來在test.sh
腳本。
APPFE_Routes mkt mkt1
我想這些mkt
和mkt1
變量傳遞expect腳本功能 通過上面的代碼。
我無法得到相同的結果。 其實我從一個文件中獲取這些變量到shell中,然後需要通過期望shell中的函數。 單獨的expect腳本不是必需的。 解決方案受到高度讚賞。
'設置文件名[LINDEX $ ARGV 0]'是'Tcl'命令,它不會在工作shell腳本。 – Dinesh
感謝Dinesh..Could請你建議我另一種方式 – user2160906
外殼相當於是'文件名= $ 1'。 – chepner