Solved

Telnet session in while loop?

Posted on 2003-11-18
3
1,123 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
Comment Utility
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
Comment Utility
Good idea! Thanks..
0
 

Expert Comment

by:dhruti14
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now