boatperl has asked for the wisdom of the Perl Monks concerning the following question:

Hello-

I have 300 + cisco 4948 IOS switches that require new code tftp'd to them. I have been trying to use net::appliance::session for this. I am able to login to the device and send 'copy tftp bootflash:" and get the next prompt. But it never fills in 10.148.48.52. I read several posts regarding custom cmd using String and Match but I can't figure it out. Here is what I'm using:

my $session_obj = Net::Appliance::Session->new( Host => "swi-87", Platform => 'IOS' Transport => 'SSH', ); $session_obj->connect( Name => $userinfo[0], Password => $userinfo[1], SHKC => 0 ); $session_obj->input_log(*STDOUT); $session_obj->begin_privileged($userinfo[1]); $session_obj->cmd("copy tftp bootflash:"); $session_obj->cmd('10.148.48.52'); $session_obj->cmd("cat4500-ipbasek9-mz.122-31.SGA9.bin"); $session_obj->close;

Can anyone provide an example? Here are the prompts the switch provides:

swi-87#copy tftp bootflash: Address or name of remote host []? 10.10.10.10 Source filename []? cat4500-ipbasek9-mz.122-31.SGA9.bin Destination filename [cat4500-ipbasek9-mz.122-31.SGA9.bin]?

I am able to capture the running config, set config-register.....using the module. I just can't get past the above prompts. I appreciate any assistance. Thanks

Replies are listed 'Best First'.
Re: net:appliance::session copy tftp bootflash:
by markkawika (Monk) on Sep 19, 2009 at 04:22 UTC
    Consider sending a command that includes all of the requested information already, so it doesn't prompt you for the missing info:
    copy tftp://10.148.48.52/cat4500-ipbasek9-mz.122-31.SGA9.bin bootflash +:cat4500-ipbasek9-mz.122-31.SGA9.bin

      Thank you markkawika, so simple it was brilliant. When you do this on console it still prompts for Destination filename. So I didn't think it would work. But using the below in the script works everytime:

      my $copy = ("copy tftp://10.148.48.52/cat4500-ipbasek9-mz.122-31.SGA +9.bin bootflash:cat4500-ipbasek9-mz.122-31.SGA9.bin"); $session_obj->input_log(*STDOUT); $session_obj->begin_privileged($userinfo[1]); $session_obj->cmd("$copy"); $session_obj->cmd("cat4500-ipbasek9-mz.122-31.SGA9.bin"); $session_obj->close;
      Thank you