× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I wrote a script like this once in DOS batch and what I did was this..

1. Get a list of all the remote files to download. This was done by
redirecting the results of the DIR command to a file.
2. Use that list to build the FTP script to retrieve files. This is
instead of using a *.* for MGET. One GET per item in the list worked so I
got everything that was there, and left anything new alone.
3. When done, I would make another list of local files, and compare it to
the remote file list to check for any errors.
4. If all was good, I used the initial remote list to remove files from
the serve. This way you'll never touch any new files on the server.

Worked slick. :)

Brad
www.bvstools.com


On Fri, Mar 15, 2013 at 6:03 AM, Marco Cecchi <MarcoCecchi@xxxxxxxxxxxx>wrote:

Hello,
I created a simple script that get all files in a remote then delete all:
_______________________________________________________________________
#!/usr/local/bin/expect -f
set timeout 20
spawn sftp $env(SSH_USER)@$env(SSH_HOST)
expect {
default {exit 2}
"continue connecting (yes/no)?" {send "yes\n"; exp_continue}
"assword:" {send "$env(SSH_PASS)\n"; exp_continue}
"sftp>"
}
send "get * /XML/OrdFor/Ricevuti/\n"
expect {
default {exit 2}
"not found" {exit 0}
"sftp>"
}
send "rm *\n"
expect {
default {exit 2}
"not found" {exit 3}
"sftp>"
}
send "quit\n"
exit 0

It "works" but files in that directory are dynamics so I risk to delete
someone just arrived after I copied the rest.
So I'm looking for a sample code to cycle the remote directory in order to
GET and RM each single file.

Thanks in advance,
Marco Cecchi
DATACOM Srl


_________________________________________________________________________________________________________________
Ai sensi del D. Lgs. 196/03 si precisa che le informazioni contenute in
questa e-mail ed eventuali suoi allegati sono riservate e ad uso esclusivo
del destinatario. Qualora il messaggio Vi fosse pervenuto per errore, Vi
invitiamo ad eliminarlo senza copiarlo e a non inoltrarlo a terzi,
dandocene immediata comunicazione. Grazie.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.