04-20-2007 08:14 AM
I am trying to copy multiple files from flash to a usb key. The issue isn't the media, its the proper command (if one exists). Is it possible to copy multiple files using one statment? For example:
copy flash: usbflash1:
It errors out and doesn't seem to like it.
If not possible natively, does anyone have a TCL script that can do this?
I am trying to come up with a solution to "image" a 2811 running CME (lots of config files, phone loads, etc.) by copying the flash onto a usb key.
Any advice would be appreciated.
Thanks,
Mike
04-20-2007 08:32 AM
See this thread where I gave a sample TCL script to iterate over all files:
You can modify the code to perform a copy operation instead of just printing the file names out. For example:
set fileList [glob -directory flash: -nocomplain *]
foreach file $fileList {
copy flash:/$file usbflash1:/$file
}
04-20-2007 08:39 AM
Actually, try:
set fileList [glob -directory flash: -nocomplain *]
foreach file $fileList {
copy $file usbflash1:
}
You may also want to set "file prompt quiet" in the config first so that you're not prompted for each response.
04-20-2007 09:43 AM
WOW. Worked like a charm. Thanks for that quick solution!!
04-23-2007 12:16 PM
How do you include subdirectories and the files they contain?
04-23-2007 12:20 PM
You'll have to recurse by testing to see what type of file object you've encountered. So you'll need to test each object returned by glob with "file isdirectory". For each object that is a directory, you will need to perform the same glob operation on it.
04-23-2007 12:21 PM
OK. Now to tackle that :). An example would be awesome. :>
04-23-2007 01:07 PM
This is untested, but something like:
proc copyDir { dir dest } {
set fileList [glob -directory $dir -nocomplain *]
foreach file $fileList {
if { [file isdirectory $file] } {
copyDir $file $dest
} else {
copy $file $dest
}
}
}
copyDir flash: usbflash1:
05-07-2007 01:26 PM
Thanks. Tried to run this but nothing happened.
05-07-2007 01:31 PM
The key is the last line:
copyDir flash: usbflash1:
That sets thing in motion. The copyDir proc is just a function. If you don't execute it, nothing will happen. In the above example, "flash:" is the source and "usbflash1:" is the destination.
10-05-2007 08:24 AM
I found this post and had the exact same question. I copied the following to a notepad
set fileList [glob -directory flash: -nocomplain *]
foreach file $fileList {
copy $file usbflash1:
}
saved it as copy_files.tcl
Then TFTP to internal flash of router
I went into CLI and added the following
event manager applet copy_files
event none
then I trigger manually with event manager run copy_files
it says it's triggered but I must be doing something incorrectly.
10-05-2007 09:17 AM
This is not an EEM policy, but a tclsh script. You need to run it using tclsh from exec mode:
tclsh flash:/copy_files.tcl
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide