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!
Solved! Go to Solution.
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:email@example.com/
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 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?
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.