its working now,tested it couple of times and sure now

posting the formatted code

#!/usr/bin/perl use strict; use warnings; use List::Util qw( first ); use Net::OpenSSH; use Log::Log4perl qw(:easy); Log::Log4perl->easy_init($INFO); $Net::OpenSSH::debug = -1; my $logger = get_logger(); my $username = 'admin'; my $password = 'password'; my $ip = '10.227.0.216'; $logger->info( "performing ssh to the swicth" ); my $ssh = Net::OpenSSH->new( $ip, user => "$username", password => "$password", master_opts => [-o => "StrictHostKeyChecking=no"] ); $logger->info( "listing zone on the switch $ip using zoneshow" ); my ( $out, $err ) = $ssh->capture2( "zoneshow" ); print "$out\n"; $logger->info( "zoneshow successful" ); $logger->info( "listing zone on the switch $ip using nsshow" ); ( $out, $err ) = $ssh->capture2( "nsshow" ); print "$out\n"; $logger->info( "nsshow successful" ); sleep 3; $logger->info( "create zone on the switch $ip using zonecreate" ); ( $out, $err ) = $ssh->capture2( "zonecreate \"test15\", \" 20:01:00:1 +1:0d:34:57:00\" " ); $ssh->error and die "remote find command failed: $!" . $ssh->error; print "$out\n"; $logger->info( "zonecreate successful" ); ##now add the zone to the config and save it ( $out, $err ) = $ssh->capture2( "cfgadd \"FC_DVT\", \"test15\"" ); $ssh->error and die "remote find command failed: $!" . $ssh->error; print "$out\n"; ( $out, $err ) = $ssh->capture2( { stdin_data =>"yes\n"}, "cfgsave" ) +; $ssh->error and die "remote find command failed: $!" . $ssh->error; print "$out\n"; ( $out, $err ) = $ssh->capture2( { stdin_data =>"yes\n"},"cfgenable \" +FC_DVT\""); $ssh->error and die "remote find command failed: $!" . $ssh->error; print "$out\n";

thanks all,salva,soonix,corion


In reply to Re^12: issue with code to save config on brocade swicth by Anonymous Monk
in thread issue with code to save config on brocade switch by janasec

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.