[geeks] quick expect/shell question
Bill Bradford
mrbill at mrbill.net
Fri Apr 7 12:04:35 CDT 2006
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
--
Bill Bradford
Houston, Texas
More information about the geeks
mailing list