LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   HELP Using telnet command in shell script (https://www.linuxquestions.org/questions/linux-newbie-8/help-using-telnet-command-in-shell-script-825057/)

saurabhmehan 08-09-2010 05:39 AM

HELP Using telnet command in shell script
 
I want to test connectivity between different servers using telnet.
I have Name,IP List and port in one file. Please help how i can test connectivity is successful or not?

File format will be:
Name1,127.0.0.1,80
Name2,127.0.0.2,8080

Output could be
Name1, Successful
Name2, Unsuccessful


I have prepare the code which uses curl and execute complete URL which is as follows:
for url in $(awk -F"," '{print $3}' cp_urls.txt)
do
curl -s -o "/dev/null" $url
if [ $? -eq 0 ] ; then
echo "$url = running"
else
echo "$url = not running"
fi
done
But i want to test connectivity between IP and port number specified.
Please suggest.

tlowk 08-10-2010 01:00 AM

you could use the netcat command (sometimes nc)
The version I have has even a command for this
see man nc:
" -z zero-I/O mode [used for scanning]"


All times are GMT -5. The time now is 09:14 AM.