Telnet Login + CSV text
Hello fellow penguins!
This is my first post on the forums and it's all because my research is failing me (I do actually research prior to asking for peoples help).
Let me start by stating my Problem, and my solution that I can't figure out how to put in action.
Problem: Remote PDU logins sometimes get stuck when users don't properly log out.
Solution: telnet into remote PDU using Username/Password and selecting option 4 to log out (this clears any hung state)
I wrote a script to do so-
-
#!/usr/bin/expect -f
spawn telnet x.x.x.x
expect -re "User Name"
send "USERNAME\r"
expect -re "Password"
send "PASSWORD\r"
expect -re "4- Logout"
send "4\r"
sleep 3
send "exit\r"
expect eof
-
Now here's what I need to happen.
I have a text file that's CSV:
"acctPDUID","acctID","rackPDU","username","password","ip","type"
5,3686,"1J6-East","USER","PASSWORD","x.x.x.x","APC"
7,3878,"1L17","USER","PASSWORD","x.x.x.x","APC"
11,4108,"1M24","USER",PASSWORD","x.x.x.x","APC"
13,3795,"1L10","USER","PASSWORD","x.x.x.x","APC"
How can I incorporate the CSV into my Telnet login script?
Basically only need telnet to connect to x.x.x.x with USER / PASSWORD then input the option 4
Thanks in advance! If you need any questions clarified let me know!!
Last edited by Wojk; 08-04-2011 at 01:26 PM.
|