Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 157

How to pass variable arguments to expect

$
0
0

I want to pass a variable number of arguments to a expect script:

#!/usr/bin/expectset timeout 10spawn ssh -o "StrictHostKeyChecking no" [lindex $argv 0]@[lindex $argv 2]expect "password: "send "[lindex $argv 1]\n"expect "$ "for {set i 1} {$i < [llength $argv]} {incr i 1} {   send { echo $i }}

I want to get

123

But instead I get

echo $iecho $i

Viewing all articles
Browse latest Browse all 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>