Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Telnet session in while loop?

Posted on 2003-11-18
3
Medium Priority
?
1,308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Accepted Solution

by:
kandura earned 400 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Six Sigma Control Plans

636 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