script - multiple telnets with logging


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script - multiple telnets with logging
# 1  
Old 10-05-2012
script - multiple telnets with logging

We had a system outage, and now I am trying to figure out how to get raw data to store in a log file.

I have a flat file that has multiple IP port line.
I want to telnet to each and log each.
But as soon as I connect to the first, it stays there.
This is on an HPUX 11.23 system. I dont think I can get expect on it, but, I dont know how expect can do this either.

These are non-interactive ports, so as soon I telnet to port, I am getting raw data.

Code:
exec < /var/isnms/switch.ip
while read switch port host log; do
if [ -d /var/isnms/$host ]
then
echo $host exist
else
mkdir /var/isnms/$host
fi
if [ -f /var/isnms/$host/$log ]
then
echo $log exist
echo "telnet $switch $port"
telnet $switch $port >/var/isnms/$host/$log
else
touch /var/isnms/$host/$log
echo "telnet $switch $port"
telnet $switch $port >/var/isnms/$host/$log
fi


Last edited by Corona688; 10-05-2012 at 12:19 PM..
# 2  
Old 10-05-2012
Moderator's Comments:
Mod Comment Please view this code tag video for how to use code tags when posting code and data.


telnet sticks here because it's waiting for input on stdin. Redirect telnet ... </dev/null and it shouldn't stick.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Syslog not logging successful logging while unlocking server's console

When unlocking a Linux server's console there's no event indicating successful logging Is there a way I can fix this ? I have the following in my rsyslog.conf auth.info /var/log/secure authpriv.info /var/log/secure (1 Reply)
Discussion started by: walterthered
1 Replies

2. Shell Programming and Scripting

Script which telnets to a device, runs commands and prints output to a file

I am connecting to a device using telnet, I want my script to perform certain commands : ie- show device , show inventory..etc and write the output it sees from the terminal to a file. this is what I have got : #!/usr/bin/expect -- set running 1 spawn telnet <ip address> expect ... (1 Reply)
Discussion started by: samantha123
1 Replies

3. Shell Programming and Scripting

Logging in to multiple Linux servers and running the command.

Hi, I am trying to write a script to run a command on multiple linux based servers and get the o/p. I am using ssh to login. It is a celerra box and EMC NAS product. I am able login but i am not able to run nas command nas_pool -size -all the NAS server. I am getting the following error. ... (2 Replies)
Discussion started by: jpkumar10
2 Replies

4. Shell Programming and Scripting

Logging Script!!!

I am trying to write a script that can be called by other scripts to print output to a log. I also want to be able to rotate the log file for this script with a max of 5 logs files. This is what I have so far: #/bin/ksh . /taipso75/scripts/IPSM_run_profile.sh* log=${IPSM_HOME}/log ( echo... (1 Reply)
Discussion started by: Dougj75
1 Replies

5. Shell Programming and Scripting

shell script for multiple logging

Hi All, I am preparing a script which executes following things: 1) Logs into 8 cluster one by one. 2) After logging into each cluster,it prints the cluster name & then exit from that cluster. 3) Then it logs to next cluster & peform the same task. Here is what i have written : for... (8 Replies)
Discussion started by: d8011
8 Replies

6. Emergency UNIX and Linux Support

Perl script logging via Shell script

Hello I wrote a nice Perl script that is intended to find and copy some files when getting a TERM signal. Now I wanted to make a shell script that starts/restarts the Perl script if it crashes/ends because of errors and make a log of all output the Perl Script gives. The problem is that it won't... (11 Replies)
Discussion started by: al0x
11 Replies

7. Shell Programming and Scripting

Perl script logging via Shell script

Hello I wrote a nice Perl script that is intended to find and copy some files when getting a TERM signal. Now I wanted to make a shell script that starts/restarts the Perl script if it crashes/ends because of errors and make a log of all output the Perl Script gives. The problem is that it won't... (1 Reply)
Discussion started by: al0x
1 Replies

8. Shell Programming and Scripting

logging into another server through script

Hello everybody, I have one small issue... :( When i'm trying to connect another unix box through below script.. #!/usr/bin/bash ssh $1 <<EOF Commands . . exit EOF But getting some syntax error "-sh: syntax error at line 2: `end of file' unexpected". I used to use... (2 Replies)
Discussion started by: raghu.iv85
2 Replies

9. UNIX for Dummies Questions & Answers

logging as su from script

Hi, I am running a script where i need to run another command in a particular folder which I do not have access so I need to login as su to that folder and run that script...what are the options I need so that I can skip interactive mode ..here is what I tried.. #! /usr/bin/sh... (2 Replies)
Discussion started by: mgirinath
2 Replies

10. Shell Programming and Scripting

logging in Shell script

How to I write to a log file all the output that is displaying on the screen? with time stamp. thankx. (3 Replies)
Discussion started by: laila63
3 Replies
Login or Register to Ask a Question