in reply to Re^10: issue with code to save config on brocade swicth
in thread issue with code to save config on brocade switch

Do you want to save the Defined zoning configuration only? (yes, y, n +o, n): [no] Operation canceled

It asks for confirmation, and as nothing is provided the operation is canceled.

Try passing stdin_data => "yes\n"

Replies are listed 'Best First'.
Re^12: issue with code to save config on brocade switch
by soonix (Chancellor) on Jul 30, 2015 at 10:40 UTC
      What it is sending via stdin is not yes but cfgsave.

        My suspicion is that the code that produces the debug output above is not the code that we are seeing.

        Maybe janasec can post the real code to produce the above output in a new node, which also uses stdin_data somewhere.

Re^12: issue with code to save config on brocade swicth
by Anonymous Monk on Jul 30, 2015 at 15:41 UTC

    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