Search code examples
batch-fileciscocisco-ios

Script in batch Cisco


It is possible to create a script, which will copy and save configuration from Cisco device?

I have already created this in a batch file:

C:\putty.exe -ssh XX.XX.XX.XX -l XXXXXX -pw XXXXXX

So I can successfully login to SW. But, if I write any other command after that in the batch file, it doesn't do anything.

Is there any way to make it work? For example:

send "configure terminal" or something like this..


Solution

  • The command you used (putty.exe -ssh) opens a session to a server. While in this session, you can execute any command and the moment you leave the session (CTLR + C most commonly) your batch script continues to execute.

    Structure is something like this:

    • Batch starts
      • SSH Session starts and ends
    • Batch script continues

    What you can do is calling the SSH function with a parameter something like:

    C:\putty.exe -ssh HOST -l USER -pw PASSWORD -m "YOURCOMMAND"
    

    For more information look here.

    OR: You use a script you will call from the switch (remote ressource)

    OR: You create a CISCO API script