-1

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..

creyD
  • 1,972
  • 3
  • 26
  • 55

1 Answers1

0

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

creyD
  • 1,972
  • 3
  • 26
  • 55
  • Realy thanks for quick answer and help, I have already added -m "C:\command.txt", and into txt file I wrote command to copy running config and it is working properly but now there is next problem, because I need to hit ENTER button. I found this: read -n 1 -s -r -p "Address or name of remote host [10.1.1.1]? " , but command line still waiting for enter Thanks – Jaroslav Fidermák Dec 20 '17 at 12:08
  • Look for a quiet (-q?) or a confirmation (-y?) option in the command options – creyD Dec 20 '17 at 12:21
  • Hello, I need only press ENTER in that script. – Jaroslav Fidermák Dec 20 '17 at 12:54
  • Then adjust it so it is a quiet command (-q?) or an preconfirmed command (most likely -y) so it will not ask you for confirmation anymore... – creyD Dec 20 '17 at 13:11
  • okay, could you please send me example of script configuration, so where to use -q or -y ? thank you – Jaroslav Fidermák Dec 20 '17 at 13:19
  • You need to look this up for the specific command causing the break. If you send me this command I may be able to look it up... – creyD Dec 20 '17 at 14:20