[geeks] quick expect/shell question

Sridhar Ayengar ploopster at gmail.com
Fri Apr 7 12:27:40 CDT 2006


If I'm not quite mistaken, it should be something like [lindex $argv 0], 
[lindex $argv 1], etc.

Peace...  Sridhar

Bill Bradford wrote:
> I'm braindead today.
> 
> Given the following shell script: (IP/password/hostname masked)
> 
> root at system:/web/cpreq> cat add2aruba 
> #!/usr/local/bin/expect -f
> set timeout 30
> spawn /usr/local/bin/ssh bbradford at 0.0.0.0
> match_max 100000
> expect "bbradford at 0.0.0.0's password: "
> send "password\r"
> expect "(ARUBA) >"
> send "enable\r"
> expect "Password:"send "enable\r"
> expect "(ARUBA) #"
> send "local-userdb add username testuser password testpass expiry duration 1440 role guest\r"
> expect "(ARUBA) #"
> send "exit\r"
> expect "(ARUBA) >"
> send "exit\r"
> expect eof
> 
> It works - but I want to be able to use variables in place of "testuser",
> "testpass", and the duration.. e.g., I want to be able to do 
> "./add2aruba guest pass 1440" and have it do "local-userdb add username 
> guest password pass expiry duration 1440 role guest" automatically.
> 
> Tried using $1 $2 $3 etc, but that didn't work..
> 
> Suggestions?
> 
> Bill
> 



More information about the geeks mailing list