Brocade Switch Perl Script

Joined
Aug 16, 2016
Messages
1
Reaction score
0
I am very new to perl scripting; and I need help insuring that I get everything in the right order for the script I am working on.

I am trying to ssh from a UNIX environment to multiple switches and collect data; at the same time place it in a csv format; I cannot use modules because it is a restricted environment.

Please helping point with script.

Thanks

Script:
#!/usr/bin/perl

#---------------------------------------------------------------------------------------------------
#---- This script was design to remote(ssh) connect to Storage Devices and perform a Cli command
#---- Version 1.0
#---- Change Date: 08/17/2016
#---------------------------------------------------------------------------------------------------

use 5.010;
use strict;
use warnings;

#---------------------------------------------------------------------------------------------------
#--- This process will open the file with the device information
#---------------------------------------------------------------------------------------------------

my $hostFile = 'device.txt';
my $commandFile = 'command.txt';
my $cmd;


open my $DEVICELIST, '<', $hostFile
or die "can't open devicelist: $!";

while (<$DEVICELIST>)
{
my @deviceList = split /\n/;

my $deviceHost = shift( @deviceList); # first Read


# print "$deviceHost\n";


#---------------------------------------------------------------------------------------------------
#--- This process will open the file with Cli commands
#---------------------------------------------------------------------------------------------------

open my $CLICOMMAND, '<', $commandFile
or die "can't open clicommand: $!";

while (<$CLICOMMAND>)
{
my @clicommand = split /\n/;

my $clicommand = shift( @clicommand); # Second Read


# print "$clicommand\n";


#---------------------------------------------------------------------------------------------------
#--- This section perform's the ssh connection and the cli command
#----------------------------------------------------------------------------------------------------

$cmd = ("ssh admin\@$deviceHost\n $clicommand\n");
print"excuting '$cmd'";
print `$cmd`;
}
Text files:

command.txt
switchshow
firmwareshow

device.txt
brocadeswitch1
brocadeswitch2

Note..
switchshow output

switchName: ajsftestbfs51
switchType: 62.0
switchState: Online
switchMode: Native
switchRole: Principal
switchDomain: 100
switchId: fffc64
switchWwn: 10:00:00:05:1e:d3:ad:00
zoning: ON (SANtest_fcs0)
switchBeacon: OFF
FC Router: OFF
HIF Mode: OFF
Allow XISL Use: OFF
LS Attributes: [FID: 128, Base Switch: No, Default Switch: Yes, Address Mode 0]

Index Slot Port Address Media Speed State Proto
============================================================
0 1 0 640000 id N8 Online FC F-Port 50:05:07:63:00:53:21:14
1 1 1 640100 id N8 No_Light FC
2 1 2 640200 id N8 Online FC F-Port 1 N Port + 3 NPIV public
3 1 3 640300 id N8 Online FC F-Port 1 N Port + 2 NPIV public
4 1 4 640400 id N8 No_Light FC
5 1 5 640500 id N8 No_Light FC
6 1 6 640600 id N8 No_Light FC
7 1 7 640700 id N8 No_Light FC
8 1 8 640800 id N8 No_Light FC
9 1 9 640900 id N8 No_Light FC
10 1 10 640a00 id N8 No_Light FC
11 1 11 640b00 id N8 No_Light FC
12 1 12 640c00 id N8 No_Light FC
13 1 13 640d00 id N8 No_Light FC
14 1 14 640e00 id N8 No_Light FC
15 1 15 640f00 id N8 No_Light FC
128 1 16 648040 id N8 No_Light FC
129 1 17 648140 id N8 No_Light FC
130 1 18 648240 id N8 Online FC F-Port 50:05:07:68:01:40:bb:b7
131 1 19 648340 id N8 Online FC F-Port 50:05:07:68:01:40:ba:af

firmwareshow output:

Slot Name Appl Primary/Secondary Versions Status
--------------------------------------------------------------------------
4 CP0 FOS v7.4.1c ACTIVE *
v7.4.1c
5 CP1 FOS v7.4.1c STANDBY
v7.4.1c

All help will be welcome.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top