cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
10938
Views
0
Helpful
22
Replies

EEM copy multiple file from flash to ftp

vaba
Level 1
Level 1

Hi,

I am trying to copy multiple files from flash to a FTP server.  Is it possible to copy multiple files using one statement?  For example:

First i type

dir flash: | i file
166  -rw-         73986              Oct 7 2010 12:25:36 +03:00  file1.817
167  -rw-         73265              Oct 7 2010 13:26:08 +03:00  file2.861
168  -rw-         204278            Oct 8 2010 13:38:06 +03:00  file3.950
 

And i need to copy all file begin with name "file" to ftp or tftp server.

copy flash:/file1.817 ftp://username:passwd@10.10.10.1/
copy flash:/file2.861 ftp://username:passwd@10.10.10.1/
copy flash:/file3.950 ftp://username:passwd@10.10.10.1/

Is this possible to do this with EEM or TCL script automatically

Can you give me some examples?

Thanks in advanced

22 Replies 22

The way the code was written, if the FTP server is down, the delete path should never be encountered.  Now if the server is taken down after the check is done, then the actual FTP may fail with an unexepected error, and thus the files will be deleted.  I can't tell what is happening based on this log, though.  I don't see the files getting deleted when the server is down.

What error do you see when you initiate the FTP transfer when the server is down?

So sorry my english is no so good, Those are the error messagges that I get when my server is down by line command (/etc/init.d/vsftp stop), I do not need make a backup of the running, this was the reason because I disable this part of the script at first time.

R3#copy running-config ftp://192.168.99.253/cdr/pruebalts.txt

Address or name of remote host [192.168.99.253]?

Destination filename [cdr/pruebalts.txt]?

Writing cdr/pruebalts.txt

%Error writing ftp://192.168.99.253/cdr/pruebalts.txt (Undefined error)

R3#telnet 192.168.99.253 21

Trying 192.168.99.253, 21 ...

% Connection refused by remote host

R3#

Regards and I really apreciate your effort.

This error is accounted for in my original code.  I don't know why the files would be deleted in that case.  Again, your previous log didn't show any problem that I could see.  The files only got deleted when they were transferred.  If you've modified my script, maybe the modifications are causing a problem.  Post the actual script you're using.

Hi, this is the script that I am running on my Cisco.

Regards

Try this version.

Thanks a lot Josep, I am going to test this new file, just a short question about this new script, what is the difference on this script with my script.

Regards

http://www.cisco.com/c/en/us/td/docs/ios/fundamentals/command/reference/cf_book/cf_a1.html#wp1047206

 

The following example shows how to create a TAR file. The command writes the contents of the new-configs directory on the local flash device to a file named saved.tar on the TFTP server at 172.20.136.9.

Switch# archive tar /create tftp:172.20.136.9/saved.tar flash:/new-configs

I think you should add this line to prevent overwriting files on FTP server with unclosed ones from previous script start:

    puts "FTP SERVER $ftpServer IS OPEN"
    set fileList [glob -directory flash: -nocomplain "cdr/cdr.*"]
+ cli_write $cli1(fd) "file-acct flush with-close"
   foreach file $fileList {

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: