Fibre Channel (SAN)

Reply
New Contributor
Posts: 3
Registered: ‎04-14-2011

setcontext command in a perl script.

Hello,

I need to to get information out of the logical switches by way of a perl script, I am using the module "Perl:Smiley FrustratedSH2" and I am able to login to the switch but a setcontext command is not working. I there anybody that can help me with this? Thank you very much in advance.

regards Allevatore.

Frequent Contributor
Posts: 141
Registered: ‎05-26-2009

Re: setcontext command in a perl script.

Without your script I don't know why it's failing, but could you workaround the usage of setcontext by catching the required information via fosexec?

New Contributor
Posts: 3
Registered: ‎04-14-2011

Re: setcontext command in a perl script.

Thanks for the fast awnser Sebastian,

I tried the fosexec command like fosexec --fid 3 -cmd "portstatsshow  1/17" but this commands works only if you are logged into the logical switch.

 

With the Perl script (ssh2) I am able to log into the default switch, but I am not able to do a setcontext to an other logical switch. So I am open for ideas.

 

 

New Contributor
Posts: 3
Registered: ‎04-14-2011

Re: setcontext command in a perl script.

Finaly I noticed what was wrong on the command: There is a space to much between portstatsshow and the blade/port number and for the fosexec command that is a problem, directly on the logical switch the extra space is not a problem.

 

So we can use the fosexec command to run all kind of commands on the logical switches, but I am still open for ideas on the Perl/ssh2 script with the setcontext command.

 

New Contributor
Posts: 3
Registered: ‎03-22-2015

Re: setcontext command in a perl script.

thank you very much for the command hint. i was almost searching for a way to had stdin to use setcontext in my plink script until i noticed this option fosexec --fid 119 -cmd "porterrshow"

 

Smiley Happy

Occasional Visitor
Posts: 1
Registered: ‎02-13-2008

Re: setcontext command in a perl script.

[ Edited ]

I have the same issue with setcontext and Net:: SSH2, my perl script is as follows:

----
my $ssh2 = Net:Smiley FrustratedSH2->new();                                                             # setup new connection.
$ssh2->connect($swip);

$ssh2->auth_password($user,$pass);

my $channel = $ssh2->channel();                                                         # create a ssh channel

my $sshrc = $channel->exec($cmd);                                                    # run command on the box
$channel->read($buf1, BUFLEN);                                                        # read the output and put it in $buf1

print "The output from the command: $cmd\n";
print "\$sshrc=$sshrc  (1=OK  0=NOK)\n";
print "$buf1";

$channel->close();                                                                                # close the channel

$ssh2->disconnect();                                                                            # Close the connection

----

==> if I do this:
my $cmd   = "\"setcontext 8\";switchname";

 

The output from the command: "setcontext 8";switchname
$sshrc=1  (1=OK  0=NOK)
myphysicalswitchname

 

==> So it gives me the name of the physical switch (FID 128), but NOT the name of mylogicalswitch8 (FID 8)
which I expected after the setcontext 8 command

 

==> and if I do this:
my $cmd   = "fosexec --fid 8 -cmd \"echo y|cfgenable MyFabricX0\"";

 

The output from the command: fosexec --fid 8 -cmd "echo y|cfgenable MyFabricX0"
$sshrc=1  (1=OK  0=NOK)

---------------------------------------------------

"echo" on FID 8:

Failed to execute the command on logical switch with FID 8

 

==> So the fosexec doesn't work because the echo is not recognised.

 

How can I issue a cfgenable (including the required ‘yes’) against a logical switch in a Virtual Fabric ? because setcontext does not seem to arrive at the logical switch and fosexec does not accept the echo command.


Any help would be appreciated.

Join the Community

Get quick and easy access to valuable resource designed to help you manage your Brocade Network.