cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3920
Views
9
Helpful
12
Replies

Simple copy/paste to upgrade IOS

the-lebowski
Level 4
Level 4

Trying to get a simple copy/paste template to configure my switches and upgrade them.  However the copy tftp commands stop working when the switch asks to save and confirm the reload.  Any ideas what I can do to send the 'yes' and confirm?   Ignnore the tftp error as I am just testing this as of now. 

copy tftp flash

10.10.10.100

c2960s-universalk9-mz.122-58.SE1.bin

/r

conf t

boot system flash:c2960s-universalk9-mz.122-58.SE1.bin

end

reload /noverify

yes

/r

OUTPUT:

sw12-s#copy tftp flash

Address or name of remote host [10.10.10.100]? 172.23.18.99

Source filename [c2960s-universalk9-mz.122-58.SE1.bin]? c2960s-universalk9-mz.122-58.SE1.bin

Destination filename [c2960s-universalk9-mz.122-58.SE1.bin]? /r

Accessing tftp://172.23.18.99/c2960s-universalk9-mz.122-58.SE1.bin...

%Error opening tftp://172.23.18.99/c2960s-universalk9-mz.122-58.SE1.bin (Timed out)

sw12#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

sw12(config)#boot system flash:c2960s-universalk9-mz.122-58.SE1.bin

sw12(config)#end

sw12#reload /noverify

System configuration has been modified. Save? [yes/no]: yes

% Please answer 'yes' or 'no'.

System configuration has been modified. Save? [yes/no]:

*Feb 28 16:54:04.729 PST: %SYS-5-CONFIG_I: Configured from console by console

% Please answer 'yes' or 'no'.

System configuration has been modified. Save? [yes/no]: yes

I have to manually hit enter to confirm yes and not sure what to send to get it to work.

12 Replies 12

Andras Dosztal
Level 3
Level 3

If you have a Linux box, you can use Expect to telnet into your device and issue the commands.

Do you know Expect? I can give you an example later today.


Sent from Cisco Technical Support Android App

Robert R
Level 1
Level 1

I would insert copy run start to eliminate the prompt to save, and then try sending a blank line after the reload since confirm is the default for the reload command.

Not sure what /r is doing for you, ..

ie..

copy tftp flash

10.10.10.100

c2960s-universalk9-mz.122-58.SE1.bin

/r

conf t

boot system flash:c2960s-universalk9-mz.122-58.SE1.bin

end

copy running-config startup-config

reload /noverify

/r  <-- don't need this, but you definitely should hit enter twice in your editor after the reload command to ensure the CR gets stored in the text.

Hope it helps.

Rob

Thanks Rob.

I was told that /r sends a return to the switch, but apparently it doesn't, I am able to get it working sort of.  I need DHCP on the management interface but if I simply copy paste the commands below the DHCP offer/receive window is too long and the rest of the commands fail because it hasn't gotten a DHCP ip address yet.  Is there a way to pause/wait for 5 seconds?

Also after I upload the ios from the tftp server rest of the commands aren't sent so there must be some timeout during the upload. 

conf t
interface fastethernet0
ip address dhcp
end
copy tftp flash
10.10.10.100
c2960s-universalk9-mz.122-58.SE1.bin
c2960s-universalk9-mz.122-58.SE1.bin
conf t
boot system   flash:c2960s-universalk9-mz.122-58.SE1.bin
end
copy   running-config startup-config
startup-config
reload

If I wait for DHCP then paste the rest it gets this far and stops, never sets the boot order and never reloads. 

Switch#copy tftp flash

Address or name of remote host [10.10.10.100]? 10.10.10.100

Source filename [c2960s-universalk9-mz.122-58.SE1.bin]? c2960s-universalk9-mz.122-58.SE1.bin

Destination filename [c2960s-universalk9-mz.122-58.SE1.bin]? c2960s-universalk9-mz.122-58.SE1.bin

Accessing tftp://10.10.10.100/c2960s-universalk9-mz.122-58.SE1.bin...

Loading c2960s-universalk9-mz.122-58.SE1.bin from 172.23.18.99 (via FastEthernet0): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

[OK - 13245186 bytes]

13245186 bytes copied in 181.163 secs (73112 bytes/sec)

Switch#

Any ideas for how to pause or wait? 

cadet alain
VIP Alumni
VIP Alumni

Hi,

just type y for first question and hit enter to confirm

and if you don't want to answer questions for the copy command just use the  IP and filename in the command and in global config enter

following command file prompt quiet

Regards.

Alain


Don't forget to rate helpful posts.

Don't forget to rate helpful posts.

Thanks for the 'file prompt quiet' which helped. 

Robert R
Level 1
Level 1

It sounds like you need a script to accomplish this.

There are Telnet/SSH clients (I use SecureCRT) that have a scripting functionality built into it.

Basically you log into the IOS device, click start recording script and begin going line by line through your commands, prompts, waits, and all.  Once that's done, click stop recording and it saves it to a script file which can be run on any other device that you log into.

In my case, SecureCRT, creates a script file with integrated "waits" built in which it will then interpret accordingly and issue the commands only when the previously recorded prompt appears.

For example.

The following script was created to change the description of the gi 0/1 interface, ping an ip 500 times and then remove the description from that same interface.  notice the crt.Screen.WaitForString "301-Rob-3560-S1(config)#" lines that tell SecureCRT to not send another command until it reads that string from the device.

The logic of the script is all handled by secureCRT.

#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
crt.Screen.Send "conf t" & chr(13)
crt.Screen.WaitForString "301-Rob-3560-S1(config)#"
crt.Screen.Send "interface gi 0/1" & chr(13)
crt.Screen.WaitForString "301-Rob-3560-S1(config-if)#"
crt.Screen.Send "desc Test Description" & chr(13)
crt.Screen.WaitForString "301-Rob-3560-S1(config-if)#"
crt.Screen.Send "end" & chr(13)
crt.Screen.WaitForString "301-Rob-3560-S1#"
crt.Screen.Send "ping ip" & chr(13)
crt.Screen.WaitForString "Target IP address: "
crt.Screen.Send "10.64.1.1" & chr(13)
crt.Screen.WaitForString "Repeat count [5]: "
crt.Screen.Send "500" & chr(13)
crt.Screen.WaitForString "Datagram size [100]: "
crt.Screen.Send chr(13)
crt.Screen.WaitForString "Timeout in seconds [2]: "
crt.Screen.Send chr(13)
crt.Screen.WaitForString "Extended commands [n]: "
crt.Screen.Send chr(13)
crt.Screen.WaitForString "Sweep range of sizes [n]: "
crt.Screen.Send chr(13)
crt.Screen.WaitForString "301-Rob-3560-S1#"
crt.Screen.Send "conf t" & chr(13)
crt.Screen.WaitForString "301-Rob-3560-S1(config)#"
crt.Screen.Send "interface gi 0/1" & chr(13)
crt.Screen.WaitForString "301-Rob-3560-S1(config-if)#"
crt.Screen.Send "no desc" & chr(13)
crt.Screen.WaitForString "301-Rob-3560-S1(config-if)#"
crt.Screen.Send "end" & chr(13)
End Sub

Again, without scripting, I don't know of anyway to incorporate a pause into what you are trying to accomplish.

I don't believe Putty has a scripting functionality built in. 

Hope that helps.

Rob

Yeah a script would work but I am not well versed on scripting out of the box cisco configurations. 

I use secureCRT to but never thought to do it that way.  Obvisouly anyway who wanted to deploy this script would have to use secureCRT as well correct?  Also does it automatically create the waits or do you have to add those manually?

I will give it a shot and see what happens.

Leo Laohoo
Hall of Fame
Hall of Fame

This question is not a dumb question.  It's relevant.


Can you please explain what you are trying to achieve?  Are you pre-staging a stack of switches for deployment?  I mean, are you doing this:

1.  Open a box of switches;

2.  Upgrading the IOS to your standard level; and

3.  Configuring each switches?

If this is what you are trying to accomplish, then I have been automating our switch build for the last 18+ months by using Cisco's Zero-Touch SmartInstall.

Thanks man. 

1. yes

2. yes

3. yes

Somethings I am not exactly clear on:

1. config template - is this just a copy of a running-config catered to the specific switch?  IE MGMT IP, hostname, logging servers, etc...If so then you need a specific template for each switch correct? If not then you still need to touch the switches to set specific ip/route information correct? 

2. Can you post a sanitzed copy of one your config templates so I can get an idea of what I can and can't do?

Basically I want zero touch install with basic standardized configurations and specific IP addressing information.

1. config template - is this just a copy of a running-config catered to the specific switch?  IE MGMT IP, hostname, logging servers, etc...If so then you need a specific template for each switch correct? If not then you still need to touch the switches to set specific ip/route information correct?

Yes and no.  Let me explain.  The "config template" is a GENERIC set of configuration lines.  Configurations such as AAA/TACACS/RADIUS are prime examples.  Specific configurations, such as management IP address and/or hostname, is what I'd like to define as "dynamic configuration".

Yes, you can do that but if you are staging multiple switches, then that means that all the switch will have the same management IP address.

One of the realized objective of Zero-Touch is chances of putting the wrong and/or incomplete configurations is minimize.  The only "human intervention" required is to enter the appliance-specific informations, such as:  Management IP address, SNMP, Banner, hostname, etc.  And the appliance-specific informations to be entered are alot shorter.

2. Can you post a sanitzed copy of one your config templates so I can get an idea of what I can and can't do?

See attached.

Daniel McDavid
Level 1
Level 1

Why not use the .tar file and the archive command?

archive download-sw /overwrite /force-reload tftp://[remote file location]

Thanks daniel that helped as well.  So the easiest way I have this is as follows:

1. settting mangement interface to dhcp

2. run archive download.....(copy IOS, install and reboot)

3. copy/paste generated config file from excel

All done via console, streamlined enough for me. 

Thanks all