Solved

How to load and execute a script to an ERS switch?

  • 3 January 2020
  • 5 replies
  • 1116 views

Hi all,

I am trying to figure out a way to load a script and store it on an ERS switch (in my case 4800 running 5.12 code) and then execute it.  I have figured out the script blocks but those appear to just be pointers to off board scripts that get uploaded and run when you do the “script run x” command (where x is the table entry number)  You create that entry using the config command “script 1 usb rename.scr” for instance to create a pointer to the script called rename.scr on the usb stick.

I don’t really want to pull the script from a usb or tftp server or whatever… don’t want to have to rely on outboard connectivity if I can put the script on the box ahead of time.  I also was hoping I could load a “revert” script ahead of time so if I wanted to go back I wouldn’t have to manually type a bunch of commands or reboot entirely but unless my error is minor enough that I can still get to the ftp server, it looks like I’m out of luck.

I also don’t want to push a whole config (ascii or binary) to the box to make a few changes.   It appears I can copy a script (copy usb script...) to one of the “blocks” but don’t see a command to execute it once it is there.  I guess that is just for booting the box off of a bull ascii config?? 

So back to question 1… Is there a way to copy a full script to an ERS switch and store it so that I can then execute it without having to have connectivity to an outboard server?

icon

Best answer by Ludovico Stevens 6 January 2020, 10:29

You can run the scripts manually, with “script run <id>” but the script file is fetched at run time (it is not stored on the switch). The ERS does not really have a proper file system so it is a bit limited in what user can store on it. If you are able to permanently leave a USB stick in the switch, you should be able to achieve what you are looking for.

Here is a test I did..

Little script, as text file “script.cfg” on my TFTP server:

enable
config term
vlan create 666 type port
end

Set it as script 1 on ERS:

ERS4800-1(config)#% script 1 tftp 10.8.12.10 script.cfg
ERS4800-1(config)#% show script 1
Table index: 1
Load script on boot: No
Script source: tftp://10.8.12.10/script.cfg
ERS4800-1(config)#%

Note that the switch does not even attempt to fetch the file.

I want to run the script manually:

ERS4800-1(config)#% script run 1
Downloaded file successfully, executing . . .

ERS4800-1(config)#enable
ERS4800-1(config)#config term
Enter configuration commands, one per line. End with CNTL/Z.
ERS4800-1(config)#vlan create 666 type port
ERS4800-1(config)#end
ERS4800-1#%

Only now the ERS fetches the file and executes it.

Not sure how useful this can be; it simply allows you to store the script filename and TFTP server IP upfront; otherwise the same can be achieved directly like this:

ERS4800-1#% configure network address 10.8.12.10 filename script.cfg
Downloaded file successfully, executing . . .

ERS4800-1#enable
ERS4800-1#config term
Enter configuration commands, one per line. End with CNTL/Z.
ERS4800-1(config)#vlan create 666 type port
% VLANs 666 already exist
ERS4800-1(config)#end
ERS4800-1#%

 

View original

5 replies

Userlevel 4

You can run the scripts manually, with “script run <id>” but the script file is fetched at run time (it is not stored on the switch). The ERS does not really have a proper file system so it is a bit limited in what user can store on it. If you are able to permanently leave a USB stick in the switch, you should be able to achieve what you are looking for.

Here is a test I did..

Little script, as text file “script.cfg” on my TFTP server:

enable
config term
vlan create 666 type port
end

Set it as script 1 on ERS:

ERS4800-1(config)#% script 1 tftp 10.8.12.10 script.cfg
ERS4800-1(config)#% show script 1
Table index: 1
Load script on boot: No
Script source: tftp://10.8.12.10/script.cfg
ERS4800-1(config)#%

Note that the switch does not even attempt to fetch the file.

I want to run the script manually:

ERS4800-1(config)#% script run 1
Downloaded file successfully, executing . . .

ERS4800-1(config)#enable
ERS4800-1(config)#config term
Enter configuration commands, one per line. End with CNTL/Z.
ERS4800-1(config)#vlan create 666 type port
ERS4800-1(config)#end
ERS4800-1#%

Only now the ERS fetches the file and executes it.

Not sure how useful this can be; it simply allows you to store the script filename and TFTP server IP upfront; otherwise the same can be achieved directly like this:

ERS4800-1#% configure network address 10.8.12.10 filename script.cfg
Downloaded file successfully, executing . . .

ERS4800-1#enable
ERS4800-1#config term
Enter configuration commands, one per line. End with CNTL/Z.
ERS4800-1(config)#vlan create 666 type port
% VLANs 666 already exist
ERS4800-1(config)#end
ERS4800-1#%

 

Ludo,

Thanks for the follow up.  After a bit more lab work I had gotten to the same understanding that you are describing here but kept wondering if I was just missing something as the documentation does not really spell this out very well.  No way to store the script within the ERS memory/locally unless you have a USB plugged in.  The script is pulled and then immediately executed at the time the “script run” command is executed.  Not my ideal, but at least I know what is possible now and can work within that framework.

The one thing that I think makes this useful is that the script (once fetched) does execute even if a command executed early in the script would cause a network disconnect from server from which the script was pulled.  This allows me to do things like execute a script from across the network, even if the network connection is lost as part of the process.  In my own case, I will turn off autosave, set a reload on a 15 minute delay and then execute commands that will cause a (hopefully) temporary lack of connectivity.  Then all I do is reconnect to the switch when it become available again, do a reload cancel and restore autosave and I’m back in business.

Thanks again for the clarification.

Ciao

 

 

Hi Jack and Ludo,

I thought this would be what I needed but I have a problem:

If I want to run a command such as

(config)#no switch 

which comes back with a prompt “Are you sure? Y/N”

If I put a “y” in my script it seems to be ignored and so my script fails.

Is there a way to get the response to be read from the script or is there a better way?

 

thanks,

chris.

 

Hi,

further to above: (it should have read

(config)# no switch ip address

)

I can get around this issue simply by configuring

(config)# no ip routing

then run 

(config)# ip address switch *IP_address> <IP_Mask> default-gateway <dgw_IP>

 

Unfortunately its still not working, but (obviously) I get cut off at the above command and can’t see what’s going wrong.  If I run the script manually from the serial port I get no errors.

 

Back to the drawing board.

Userlevel 1

I would advise against leaving a USB stick permanently inserted. It can cause the SNMP process to lock up when a switch is polled and the only way to restore is a reboot. If your network doesn’t have any vulnerability scans occurring then you should be safe.
ERS454800-2868. Still listed as a limitation in the latest (final?) 4800 release notes.
https://documentation.extremenetworks.com/release_notes/ers_series/ers4800/ERS4800ReleaseNotes_5.12.6_RN.pdf

Also, doesn’t help with a 4800, but the 4900s have a new RamDisk partition where you can store files and SW/FW images. It’s not that big, but it works good for ascii scripts. You can just WinSCP to the switch and drop files in. Commands are show ramdisk-files, config ramdisk, download ramdisk

 

Reply