another script for telnet connection
first thing i have to say, i cannot use the following:
expect netcat nmap this has to be in bash and has to be in telnet. my senior admin asked me to come up with a script to telnet to a server on port 110, actually log in, be able to list, and then log out. if i am able to do those things, then awesome, no action needed. if, however, i am unable to establish a connection, i need to be notified via email no connection established. i have the log in portion of the script developed and it works, but i do not know how to finish the script if the connection cannot be established. any input and help is appreciated. here is the first part of my script PHP Code:
|
You could make a seperate check, before going on with the log in, such as:
Code:
telnet 127.0.0.1 > /dev/null 2>&1 || echo "connection refused, so i wont bother logging in" |
er*
|
Expect is built for this and can handle the input/output plus timeouts etc....sys admin , is your school teacher?
|
no, sys admin is not my school teacher, i work with him and i'm not sure if he's giving me this to help me with scripting or if there is another reason.
|
I've given you a simple example and explanation of how to do this. Is there a problem?
|
Of course you can go that way, but that script is very weak. If you are not going to automate a lot of things using telnet is the way to go.
Now if you want something more powerful, Perl has a nice Telnet Module. http://search.cpan.org/~jrogers/Net-.../Net/Telnet.pm |
Quote:
and how to implement it in a non interactive script. |
In general, using telent to handle passwords is NOT secure. There is no encryption used so anyone sniffing the network has the password...
ssh (with RSA authentication) can do this without a problem, without even needing a password, and be more secure at the same time. |
Quote:
i am now going to focus on this method and i think it will give me what i need: Initiates the login session to port 110, using netcat and an input file that will have the log in credentials Capture the output to a file Grep the output file for Authentication failed IF Authentication failed exists = notify Authentication does not exist = no action needed once i get it developed and working i'll post it up for your input. |
seems so simple now but man this hurt my head.
Code:
#!/bin/bash |
All times are GMT -5. The time now is 12:36 PM. |