Brocade Switch Perl Script

Discussion in 'Perl' started by Robert Lamar, Aug 19, 2016.

  1. Robert Lamar

    Robert Lamar

    Joined:
    Aug 16, 2016
    Messages:
    1
    Likes Received:
    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.
     
    Robert Lamar, Aug 19, 2016
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Wet Basement
    Replies:
    1
    Views:
    2,972
    BobMonk
    Jul 15, 2003
  2. dpackwood
    Replies:
    3
    Views:
    2,376
  3. pj
    Replies:
    3
    Views:
    590
  4. Petterson Mikael

    Execute another perl script from my perl script

    Petterson Mikael, Jan 5, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    414
    Paul Lalli
    Jan 5, 2005
  5. xdarcos@hotmail.com

    CGI: Execute a perl script inside another perl script

    xdarcos@hotmail.com, Jan 12, 2005, in forum: Perl Misc
    Replies:
    20
    Views:
    1,565
    Gunnar Hjalmarsson
    Jan 18, 2005
  6. anywherenotes@gmail.com

    how to run perl script from a perl script?

    anywherenotes@gmail.com, Apr 13, 2005, in forum: Perl Misc
    Replies:
    6
    Views:
    399
    Tad McClellan
    Apr 14, 2005
  7. yong
    Replies:
    8
    Views:
    7,971
    Anno Siegel
    Jan 20, 2006
  8. cytec123187@gmail.com

    Switch Within A Switch

    cytec123187@gmail.com, Apr 22, 2006, in forum: Javascript
    Replies:
    7
    Views:
    529
    Lasse Reichstein Nielsen
    Apr 22, 2006
Loading...