cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3081
Views
0
Helpful
2
Replies

EEM and TCL: how to delete multiple files from flash?

eseifer
Level 1
Level 1

Hello,

I have been working on using EEM and TCL to copy multiple files (starting with file.x) from flash to an FTP server and once they have been copied, i want to delete them from flash. For example:

sho flash | i file.x

211         33 Jun 18 2011 00:36:34 file.x-01

212         33 Jun 18 2011 00:36:38 file.x-02

213         33 Jun 18 2011 00:36:40 file.x-03

214         33 Jun 18 2011 00:36:44 file.x-04

215         33 Jun 18 2011 00:36:48 file.x-05

Searching previous examples of EEM and TCL  I found the following TCL structure to copy the file via FTP:

set fileList [glob -directory flash: -nocomplain "file.x*"]

foreach file $fileList {

    if [catch {cli_exec $cli1(fd) "copy $file ftp://10.0.0.1/"} _cli_result] {

        error $_cli_result $errorInfo

     }

}

This work.

However I can't seem to figure out what TCL structure to use to delete them from flash. I tried variations of the above, but they failed.

Can anyone help out?

Thank you for your help in advance!

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

You could simply cli_exec the "delete" command.  If you want to use pure Tcl, then add the following in the foreach loop:

if { [catch {file delete -force -- $file} result] } {

    error $result $errorInfo

}

View solution in original post

2 Replies 2

Joe Clarke
Cisco Employee
Cisco Employee

You could simply cli_exec the "delete" command.  If you want to use pure Tcl, then add the following in the foreach loop:

if { [catch {file delete -force -- $file} result] } {

    error $result $errorInfo

}

That was perfect! Thanks Joe!