Solved

Telnet session in while loop?

Posted on 2003-11-18
3
1,182 Views
Last Modified: 2013-01-16
I wrote a script that interfaces with some gear and at one point in the script I have to reboot the card. Now I want to create another telnet session that will re-establish the connection once the card comes back up. I want to use a way that tries to connect and if the connection does not get established then I want it to loop back and try again until the connection is back up which would mean the card has finished rebooting.

I tried adding a while loop in this manner but was unsuccessfull.  Anyone have any ideas on how to implement this?

Oh I forgot to mention that I am using Net::Telnet module for the telnet sessions.
0
Comment
Question by:ZiaTioN
3 Comments
 
LVL 18

Accepted Solution

by:
kandura earned 100 total points
ID: 9774769
it may be more efficient to just 'ping and sleep' in the while loop:

use Net::Ping;

$p = new Net::Ping;
$up = 0;
$count = 0;
while(!$up and $count<10)
{
  $up = $p->ping( $your_gear_address );
  $count++;
  sleep(2);
}
$p->close();

if($up)
{
  # continue with your telnet session

0
 
LVL 5

Author Comment

by:ZiaTioN
ID: 9789334
Good idea! Thanks..
0
 

Expert Comment

by:dhruti14
ID: 38784969
hello above script what code u wrote to continue your session please help me.. i am able to make telnet session and now i want to ping that session and if session disconnect with any reason i want to reconnect that open session....
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question