telnet to another server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting telnet to another server
# 1  
Old 07-05-2009
telnet to another server

hi all,
i wanted to write a ksh script to telnet to another server on a particular port every 5 mins in order to send out an alert if that server went down.

how do i read the response that comes back when the server is down i.e "telnet: Unable to connect to remote host: Connection refused"


ta.
# 2  
Old 07-05-2009
redirect the errors of the telnet to a file the grep for errors
If found display the appropriate error....
# 3  
Old 07-05-2009
Quote:
Originally Posted by vidyadhar85
redirect the errors of the telnet to a file the grep for errors
If found display the appropriate error....
hey thanks for the reply, just came to mind that a telnet session if left open will get automatically shut/closed by the network. is there a better way of doing this rather than using telnet ??


ta.
# 4  
Old 07-05-2009
you can use ping or an ftp session...
# 5  
Old 07-05-2009
Quote:
Originally Posted by vidyadhar85
you can use ping or an ftp session...
telnet and ftp uses different port, when telnetd is running, there is no guarantee that ftpd should be running or vice versa,
so ping on a telnet port is another alternative
# 6  
Old 07-06-2009
Ex. ping is not service test. If you like to test some tcp/ip service, use that service = only correct method to check service.
And use ip and port/service number - test only service, not own dns, ...
Create socket ex. socket.sh 111.111.111.111 23
Code:
#!/usr/bin/ksh
host=$1
port=$2
exec 4<>/dev/tcp/$host/$port
exit $?

Using that nice ksh93 script, you can do something like (check.sh):
Code:
#!/usr/bin/ksh
ip=$1
port=$2
waittime=$3
while true 
do
        ./socket.sh  "$ip" "$port"  ||  ./not_ok.sh "$ip" "$port"
        sleep $waittime
done

Code:
chmod a+rx *.sh
# ex. port 23 = usually telnet, wait 300 s
./check.sh  xx.xxx.xxx.xx  23 300 >> telnet.log 2>&1     &

Now you can write your not_ok.sh script as you like.

Last edited by kshji; 07-06-2009 at 02:32 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. SCO

Not able to telnet to server

Out of the blue for some odd reason I am no longer able to telnet to one of my SCO Unix servers. I can ping, ftp and do a traceroute to it, just cant telnet. When I attempt to telnet to it, I just get this Trying ##.##.##.##.... telnet: Unable to connect to remote host: Connection timed out ... (0 Replies)
Discussion started by: macastor
0 Replies

2. UNIX for Dummies Questions & Answers

Telnet server

I need a list of servers, that, I can try out my test program with, such as a timeserver. For example, I would need to connect to telnet server|port. (1 Reply)
Discussion started by: jon80
1 Replies

3. Homework & Coursework Questions

How to auto telnet the server from another server?

Hi All, I have a problem with auto telnet script, but I want to tell u something a) I am only a member access on the server, so not able to access 'root' account b) not able to install any software on server 3) On server, there is not install 'except' 1. The problem statement, all variables... (8 Replies)
Discussion started by: atul9806
8 Replies

4. Homework & Coursework Questions

How to auto telnet the server from another server

Hi All, I have a problem with auto telnet script, but I want to tell u something a) I am only a member access on the server, so not able to access 'root' account b) not able to install any software on server 3) On server, there is not install 'except' 1. The problem statement, all variables... (0 Replies)
Discussion started by: atul9806
0 Replies

5. Shell Programming and Scripting

How to auto telnet the server from another server using script

Hi All, I have a problem with auto telnet script, but I want to tell u something a) I am only a member access on the server, so not able to access 'root' account b) not able to install any software on server 3) On server, there is not install 'except' I have to write a script, which is ran... (0 Replies)
Discussion started by: atul9806
0 Replies

6. AIX

Unable to telnet to server

Hi, I encountered error when I telnet to my server. Error is as follows: telnetd: /bin/login: The file access permissions do not allow the specified action I am able to ssh into my server and I have checked/verified /etc/security and /etc/inetd.conf. I restarted the inetd subsystem via... (1 Reply)
Discussion started by: chongkls77
1 Replies

7. Solaris

cannot telnet after restarting server

Dear guys, Pls help me this case. I telnet normally to Solaris. After restarting it manually, I can only console, cannot telnet from my latop although I can ping it. I checked /etc/default/login /usr/sbin/in.telnetd /etc/inet/inetd.conf All these files are the same. I don't see telnet... (2 Replies)
Discussion started by: wipi
2 Replies

8. UNIX for Dummies Questions & Answers

telnet to remote server

Hi every1 well i am new to unix scripting but i have been seeking help from this forum the question i want to write a script to telnet to a remote server and put the username and pwd in the script the problem is that i want to run some commands on the remote server and get the results in a... (2 Replies)
Discussion started by: hassanabbas
2 Replies

9. UNIX for Advanced & Expert Users

I access to my server via Telnet

I use server Unix with AIX 5.2. I can't telnet to server about 5 mn, then i can access to server via telnet. This problem have again and again. Sometime can, sometime can't. I dont know why? Do you have any idea? (4 Replies)
Discussion started by: SENG
4 Replies

10. UNIX for Dummies Questions & Answers

Telnet Server

Good day, We have recently purchased an HP Compaq t5000 thin client and installed this as a management console. It runs Windows CE 5.0 as we required Internet Explorer for the managemenet of the one server (Web based management only working in Internet Explorer). We have now also installed... (4 Replies)
Discussion started by: avd
4 Replies
Login or Register to Ask a Question