Scenario:
1. Logged into a host UNIX (System A).
2. Telneting to a switch (1.2.3.4) that requires a
login/password for access. (telnet is the only method
allowed to enter switch)
3. Running a display command (e.g.: display 123/S 23/A 14)
to capture data back to a file on host UNIX (System A).
Trying to use a here document on System A as follows:
#####################################################
get-switch-data.sh
telnet 1.2.3.4 <<-EOF 2>&1 > /home/switch/sw-data/log-data
guest
guest
display 123/S 23/A 14
EOF
#####################################################
Trouble I'm running into, is with the login/password
required. How can I pass it(login/password) to telnet (I know about the -l login) option on command line telnet -l guest, but no password option), and get my log-data from the command being passed.
Anny help, Thanks!
I am also looking at trying the following with an expect script and/tcl.
I am not a user of expect/tcl so, if someone could/would
just assist me on the following to see if it is steering
me in the right direction, I would appreciate it.
Thanks!
FGG
#####################################
#!/usr/bin/expect --
spawn /usr/bin/telnet
expect "telnet>"
send "open YOUR_IP_HERE\r"
expect "ogin" # In case login is "Login or login"
send "YOUR_LOGIN_HERE\r"
expect "ssword" # In case password is "Password or password"
send "YOUR_PW_HERE\r"
expect "SOME_PROMPT (I.E. $>)"
send "YOUR_COMMANDS_HERE\r"
expect "SOME_PROMPT (I.E. $>)"
send "exit\r"
expect eof
To log, just run script name > log 2>&1
#####################################3
FGG123
1. Logged into a host UNIX (System A).
2. Telneting to a switch (1.2.3.4) that requires a
login/password for access. (telnet is the only method
allowed to enter switch)
3. Running a display command (e.g.: display 123/S 23/A 14)
to capture data back to a file on host UNIX (System A).
Trying to use a here document on System A as follows:
#####################################################
get-switch-data.sh
telnet 1.2.3.4 <<-EOF 2>&1 > /home/switch/sw-data/log-data
guest
guest
display 123/S 23/A 14
EOF
#####################################################
Trouble I'm running into, is with the login/password
required. How can I pass it(login/password) to telnet (I know about the -l login) option on command line telnet -l guest, but no password option), and get my log-data from the command being passed.
Anny help, Thanks!
I am also looking at trying the following with an expect script and/tcl.
I am not a user of expect/tcl so, if someone could/would
just assist me on the following to see if it is steering
me in the right direction, I would appreciate it.
Thanks!
FGG
#####################################
#!/usr/bin/expect --
spawn /usr/bin/telnet
expect "telnet>"
send "open YOUR_IP_HERE\r"
expect "ogin" # In case login is "Login or login"
send "YOUR_LOGIN_HERE\r"
expect "ssword" # In case password is "Password or password"
send "YOUR_PW_HERE\r"
expect "SOME_PROMPT (I.E. $>)"
send "YOUR_COMMANDS_HERE\r"
expect "SOME_PROMPT (I.E. $>)"
send "exit\r"
expect eof
To log, just run script name > log 2>&1
#####################################3
FGG123