Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 26th, 2012, 12:18 PM
abulut abulut is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 1 abulut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 49 sec
Reputation Power: 0
Perl script host loop

Hello;

While this script working, in case of not to connect a node ("BADYK01","BAGRK01", "BAHLK01", "BAHLK02", "BAHLK03") , it stops.

I want it to be continue even if it doesnt connect a node. I mean if it couldnt connect to BAGRK01, I want it to be continue and connect the other node BAHLK01.

Thanks


PHP Code:
# $interface = "1.0"
    # This PerlScript example iterates through an array of three session names
    # connecting to each one in turn. The unix 'df' command is
    # sent to each server and the output is captured to a logfile.
    
TEST1:
    
# Enable errors
    #
    
use Win32::OLE;
    
Win32::OLE->Option(Warn => 3);
    
#unlink <*.txt>;
    
$crt->Session->Disconnect();
    
# An array of session names to connect to.
    
@sessions = ("BADYK01","BAGRK01""BAHLK01""BAHLK02""BAHLK03");
    
# define some useful constants
    #
    
$true 1;
    
$false 0;
    
$StartLog $true;
    
$StopLog $false;
    
$Append $true;
    
$Overwrite $false;
    
$Raw $true;
    
$Not_raw $false;
    
# NOTE: Set your logfile path here
    #
    #$LogFile = "LOG.txt";
    #$LogFile = "$LOG.log";
    #
    
$crt->Screen->{'Synchronous'} = $true;
    
# Loop thru the array of sessions
    #
    
for ($i 0$i 5$i++) {
    
# Connect to each session using the "/s sessionname" argument.
    #
    
$crt->Session->Connect("/s " $sessions[$i]);
    
# Wait for 5 seconds, or until the login prompt appears.
    #
    
$crt->Screen->WaitForString("MAIN LEVEL COMMAND <___>");
    
# Set the name of the logfile for this session.
    #
    
$crt->Session->{'LogFileName'} = LOG ".txt";
    
# Enable logging
    #
    
$crt->Session->Log($StartLog,$Append);
    
# Send the 'df' command followed by a CR (octal 015)
    #
    
$crt->Screen->Send("EOL:;\015");
    
$crt->Screen->WaitForString("BASE TRANSCEIVER STATION ALARMS HANDLING COMMAND <EO_>");
    
$crt->Session->Log($StopLog);
    
$crt->Session->Disconnect();
    }
    
$crt->Screen->{'Synchronous'} = $false

Reply With Quote
  #2  
Old September 26th, 2012, 05:54 PM
spacebar208's Avatar
spacebar208 spacebar208 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Location: spaceBAR Central
Posts: 188 spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 9 h 11 m 26 sec
Reputation Power: 41
Can you try something like this for your connection so that you would handle any errors instead of having "Win32::OLE" invoke croak:

Code:
Win32::OLE->Option(Warn => 0);
my $ret_code  =  0;
$crt->Session->Connect("/s " . $sessions[$i]) or $ret_code = 1;

if ( $ret_code != 0 ) {
  print "**Error occurred connecting to session($sessions[$i])," .
        "Error_Code: "  . Win32::OLE->LastError()  . "\n";
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Perl script host loop

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap