5
如下面我shell脚本:如何将变量从shell脚本传递到期望脚本?
#!/bin/bash
echo "Select the Gateway Server:"
echo " 1. Gateway 1"
echo " 2. Gateway 2"
echo " 3. Gateway 3"
read gatewayHost
case $gatewayHost in
1) gateway="abc.com" ;;
2) gateway="pqr.com" ;;
3) gateway="xyz.com" ;;
*) echo "Invalid choice" ;;
esac
/mypath/abc
在上面的脚本中,我从用户输入选择&获取网关试图传递给我的abc.sh脚本是指望下面scriptshown:
#!/usr/bin/expect
set timeout 3
spawn ssh "[email protected]$gateway"
expect "password:"
send "TSfdsHhtfs\r";
interact
但我无法从shell脚本传递网关变量以期望脚本。任何人都可以告诉我如何实现这一目标?请注意,我需要使用shell脚本只是由于传统的原因(不能使用TCL脚本或期望脚本本身不能做的一切)