cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1092
Views
0
Helpful
9
Replies

EEM and TCL: how to create step verification in TCL?

eseifer
Beginner
Beginner

Hello,

With IP SLA, EEM and TCL I am trying to test connectivity to an external FTP server. If reachability goes down and is restored, I want to copy all files from flash that start with the name "file-0" to the external FTP server, then once the copy has been CONFIRMED, delete the files from flash.

My concern is that if connectivity to the external FTP server is lost during the time that the TCL is initated, my current TCL will skip the 'copy' and just delete the files from flash.

Question: How can I modify the attached TCL to only delete files from flash AFTER the script successfully copying all files to the FTP server?

Thanks in advance!

Eric

1 Accepted Solution

Accepted Solutions

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

Look closely.  This code is different.  The files will be deleted immediately after they are copied.

View solution in original post

9 Replies 9

eseifer
Beginner
Beginner

Looking at the output of "copy flash FTP" from the Telnet session with "file prompt quiet" configured, the command output shows that the file was copied:

copy flash:file-0-99999999.01-16 ftp://username:password@ftp.server/

Address or name of remote host [ftp.server]?

Destination filename [file-0-99999999.01-16]?

Writing file-0-99999999.01-16 !

60089 bytes copied in 2.796 secs (21491 bytes/sec)

Can the TCL be modified to look for the "copied" output for all of the files to be copied via FTP and if 'yes' go to the next step (delete -force -- $file) otherwise, 'break out' and skip to the 'config t' -> 'no file prompt quiet'?

Thanks.

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

This version should do what you want.  It will bail if one of the files fails to copy.

Thanks for getting back to me so soon Joe.

I tested your script and it only copies the first 7 (33 bytes each) out of 16 files and bails and none of the files are deleted. This is good.

Some files are much larger, 60KB or potentially 1MB

If i reduce the file count to 6 (33byte) files, the script works.

It appears that not enough time is allowed during the copy process to allow all of the files to be copied.

Is it possible to extend that time within the script to allow for a large amount of file transfers of files of varying sizes?

Thanks!

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

Add "maxrun 300" to the end of the event registration line at the top of the script.  This will allow the script to run for 300 seconds.  If that is not enough time, you can continue to increase it until all of the copy operations complete.

Hi Joe, thanks for the timer tip!

Unfortunately, the design of my script needs to change a bit.

Is it possible to copy, then delete, one file at a time using the '-nocomplain' variable? What would the TCL look like?

This would ensure that, in the event that the script needs to stop and bail out, it would delete from flash the files it was able to copy via FTP, so that when the script was executed again because it had to bail out, the previously copied files would not be copied again.

Thanks!

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

This version should do what you want.

Hi Joe,

this latest version appears to be the same as you initial example. Is this correct?

Eric

Joe Clarke
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

Look closely.  This code is different.  The files will be deleted immediately after they are copied.

You're right. I missed it. Initial testing works like a charm. Thanks again Joe.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Recognize Your Peers