telnet without enterin g the telnet prompt bash
i am writing a script to test for open ports using telnet
telnet $server $port if [ $? -eq 0 ] echo $port on $server open fi but telnet $server $port enters the telnet command prompt Can anyone please tell me how can i use telnet for not entering the telnet promt? |
Quote:
You can set the escape character by explicitly mention the escape character. After that you can get the exit status. Eg :1 $echo "q" | telnet -e q localhost 23 2>/dev/null;echo $? Telnet escape character is 'q'. Trying 127.0.0.1... 1 Eg: 2 $ echo "q" | telnet -e q localhost 22 2>/dev/null;echo $? Telnet escape character is 'q'. Trying 127.0.0.1... Connected to localhost. Escape character is 'q'. telnet> Connection closed. 0 -- Thanks, Bijo |
You do know there is an utility for that already - its called "nmap".
And nmap can do a lot more than just making telnet connections. http://nmap.org/book/man.html |
thnx a lot for helping :)
|
All times are GMT -5. The time now is 05:31 AM. |