Break command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Break command
# 8  
Old 02-10-2009
Hi , Two things which i wanted clarify

The reason behind the implementation is that we have multiple connections to various nodes through which files move in and out. so we are monitoring the ip also we are trying to implement the telnet functionality in this.

I have sorted out the ping command functionality by using grep option whihc would get the particular pattern and then decide accordingly.

Now the next step which i would be following is telnet.

so here i telnet to the ip with the port no

say for example

telnet 112.123.123.121 xxxx where xxxx is the port no
now here after this command is fired the telnet is connected and while logging out i type logout there and comeout. This is in case of a manual connection.

Now if i am implementing this int he script

telnet 112.123.123.121 xxxx > file1

`sleep 15`

'logout`

cat file1 | grep " connected"

if [ $? -eq 0 ]

then

echo " the node is up " | mailx -s " node connecitivty " venkidhadha@in.com

The problem which happens here is that after loggin in the logout command doesnot work as now we are not in the original system where the scirpt is present.

How can do a remote logout of telnet so that the next step "LOGOUT" works?


Sorry if this seems to be a basic question.Smilie
# 9  
Old 02-10-2009
Thanks a lot actually i have sorted that issue out. i am using a grep option and from that i am retreiving the data. Also now i need to know how do i remotely logg off my telnet seession with a vendor node from my system. I am not bale to use this in my script because the logout command in my scirpt will not work after connecting the the vendor node and oly after i log out manually the logout and the next commands in,my script works. Hope you got my point. sorry if it is too basic for you.
# 10  
Old 02-10-2009
Quote:
Originally Posted by venkidhadha
i=1
while [ $i -le 7 ]
do
k=`cat iplist |head -$i|tail -1`
ping $k
if [$? -eq 0]
then echo " The node $k is alive " | mailx -s " Network connectivity " venki_dadad @in.com

else echo " The node $k is down " | mailx -s " Network connectivity " venki_dadad @in.com
i=`expr $i + 1`
echo $i
fi
done
Assuming you only want the first 7 IP's from this file, try this also:
Code:
ips=`head -n 7 iplist`
for myip in $ips
do
     ping -c 1 $myip
     if [$? -eq 0]
     then 
         echo " The node $myip is alive " |  mailx -s " Network connectivity " venki_dadad @in.com 
     else 
         echo " The node $myip is down  " | mailx -s " Network connectivity " venki_dadad @in.com 
      fi
done

Or you could batch this in one shot like this:

Code:
ips=`head -n 7 iplist`
RESULT=""
for myip in $ips
do
     # Make this post to the console (remove the '2>&1 >> /dev/null' at the end)  or leave it so that it is quiet
     ping -c 1 $myip 2>&1 >> /dev/null
     if [$? -eq 0]
     then 
         RESULT="${RESULT} \nThe node $myip is alive "  
     else 
         RESULT="${RESULT} \nThe node $myip is down  " 
      fi
done
echo -e "${RESULT}" |  mailx -s " Network connectivity " venki_dadad @in.com


One email sent with all test results.

Last edited by ddreggors; 02-10-2009 at 10:54 PM..
# 11  
Old 02-11-2009
Quote:
Originally Posted by venkidhadha
Thanks a lot actually i have sorted that issue out. i am using a grep option and from that i am retreiving the data. Also now i need to know how do i remotely logg off my telnet seession with a vendor node from my system.
Ok, for this I think You should have a look at the program expect. It will enable You to script and automate any console/text based connection by logging in, looking for expected output and sending a predefined response.

/Lakris
# 12  
Old 02-11-2009
Quote:
Originally Posted by venkidhadha
i am using a grep option and from that i am retreiving the data.
That was why I posted AFTER you said you sorted it all out...

Why use the un-needed grep?

Look at my previous post and you will see that grep is not needed.

Code:
ips=`head -n 7 iplist`

No grep used to get these ip's.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Break in for loop

in my python script i have loop like below: for item in itemlist: if <condition>: <code> else: <code> if <condition>: if <condition>: <code> else: for type in types: if... (1 Reply)
Discussion started by: ctrld
1 Replies

2. Solaris

Can't use 'break' command, Can't access 'ok' prompt.

Hi I have A Sun Ultra Enterprise 450 server, it has Solaris installed on it. I have A serial terminal hooked up to it (nullmodem cable plugged into serial port 1 on the box, and the other end plugged into the serial port of A laptop (NEC Versa M300)) The laptop is running Ubuntu 12.04.2... (3 Replies)
Discussion started by: SomeoneTwo
3 Replies

3. Shell Programming and Scripting

How to break the line to the one above?

Hello everyone! I'm trying to make the below file1 look like file2, can anyone help? Basically I just hit backspace on every line that starts with a number. Thanks! file1: THIS#IS-IT1 4 THIS#IS-IT2 3 THIS#IS-IT3 2 THIS#IS-IT4 1 Result > file2: (4 Replies)
Discussion started by: demmel
4 Replies

4. Shell Programming and Scripting

BASH: Break line, read, break again, read again...

...when the lines use both a colon and commas to separate the parts you want read as information. The first version of this script used cut and other non-Bash-builtins, frequently, which made it nice and zippy with little more than average processor load in GNOME Terminal but, predictably, slow... (2 Replies)
Discussion started by: SilversleevesX
2 Replies

5. Shell Programming and Scripting

break: cannot break

hi guys I am working on a menu for linux... some basic stuff. but I have an issue. I got 1 server where something is working and the same thing does not work in the same way in another linux box Basically I am simulating a command line where user insert some commands and to end and go back... (7 Replies)
Discussion started by: karlochacon
7 Replies

6. Shell Programming and Scripting

how to break cat

Greetings. cat $name$telephonenumber >> telephonebook.txtI would like to break cat with the command 'break'. Pretty hard to understand huh? So to clarify it: echo "If you want to stop adding datas to your telephonebook please type 'break' if #this part is probably not good then echo... (2 Replies)
Discussion started by: buddhist
2 Replies

7. Solaris

Break command on rsc of sunfire v890 server

Hi Gurus I would like to know whether break command always work well means take the system to ok> prompt. Its depend upon sever model also. As I am facing problem when ever my system ( Sunfire V890 ) having Solaris 10 OS & oracle RAC on it goes to hang state then I run the break command from... (6 Replies)
Discussion started by: girish.batra
6 Replies

8. UNIX for Dummies Questions & Answers

Can anyone break down this find command for me?

find . "(" -name a.out -o -name core ")" -exec rm {} \; Specifically What files are trying to be found What does the -o do in this command What is the result if the files are found What does the command do if the files are not found What does the . after the word find mean thanks in... (1 Reply)
Discussion started by: knp808
1 Replies

9. Shell Programming and Scripting

break out of 'if'

is it possible? because i still need to keep on reading even though i don't want to read that particular line (7 Replies)
Discussion started by: finalight
7 Replies

10. UNIX for Dummies Questions & Answers

Insert line break in vi's command mode

Hi, When working in vi, the CTRL+j command for merging lines is very convenient. Is there an equivalent for splitting them (inserting a line break)? I often find myself pressing "i" + "return" + "esc", which I find a bit lengthy. Thanks in advance! (3 Replies)
Discussion started by: Skogsmulle
3 Replies
Login or Register to Ask a Question