CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
perl script host loop

 



abulut
New User

Sep 26, 2012, 10:22 AM

Post #1 of 2 (1355 views)
perl script host loop Can't Post

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


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;



BillKSmith
Veteran

Sep 26, 2012, 11:21 AM

Post #2 of 2 (1350 views)
Re: [abulut] perl script host loop [In reply to] Can't Post

You probably can 'trap' the error with an eval block. Refer perldoc -f eval.
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives