How to pass variables from a shell script to an expect script?

后端 未结 1 802
悲哀的现实
悲哀的现实 2020-12-06 13:41

I\'ve shell script as below:

#!/bin/bash

echo \"Select the Gateway Server:\"
echo \"   1. Gateway 1\"
echo \"   2. Gateway 2\"
echo \"   3. Gateway 3\"

rea         


        
相关标签:
1条回答
  • 2020-12-06 13:54

    From your shell script:

    /mypath/abc $gateway
    

    From your expect script:

    #!/usr/bin/expect
    
    set gateway [lindex $argv 0]; # Grab the first command line parameter
    
    set timeout 3
    spawn ssh "james@$gateway"
    expect "password:"
    send "TSfdsHhtfs\r";
    interact
    
    0 讨论(0)
提交回复
热议问题