Discussion:
FTP script to upload and overwrite files
(too old to reply)
Sandra
2005-07-22 18:15:13 UTC
Permalink
Hi all,

I'm looking for a script to upload all *.aaa files located on c:
\backup_files\ to a ftp server
open ftp.xxxxxxxxx.com
login
passwd
put c:\backup_files\*.aaa
bye

This doesn't seem to work. How do I upload a number of files?
In case the file already exists, it should be overwritten without even
asking..


Any help?

Sandra
William Allen
2005-07-22 20:05:54 UTC
Permalink
"Sandra" wrote in message
Post by Sandra
Hi all,
\backup_files\ to a ftp server
open ftp.xxxxxxxxx.com
login
passwd
put c:\backup_files\*.aaa
bye
This doesn't seem to work. How do I upload a number of files?
In case the file already exists, it should be overwritten without even
asking..
With a wildcard, you need to use MPUT, and run the script through
the FTP command with the -i (non-interactive) switch:
ftp -i -s:MyScript

Typical script contents, including making appropriate remote folder
current for uploading:

open ftp.mysitename.net
MyUserName
MyPassword
cd /work/myfiles
mput filespec*.*
quit

For Windows 95/98/ME users:
Details of controlling FTP transfers from a Batch file (includes how to
change remote file permissions): http://www.allenware.com/find?BatchFTP
This StudyPack includes advanced Batch examples to show how to record a
logfile of an FTP session, and to have progress reports shown on-screen
during a long FTP session (with Subroutine using explicit redirection).

For help with FTP, use -h switch
ftp -h

--
William Allen
Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
Batch Reference with examples http://www.allenware.com/icsw/icswref.htm
Header email is rarely checked. Contact us at http://www.allenware.com/
Sandra
2005-07-23 07:39:34 UTC
Permalink
Post by William Allen
"Sandra" wrote in message
Post by Sandra
Hi all,
\backup_files\ to a ftp server
open ftp.xxxxxxxxx.com
login
passwd
put c:\backup_files\*.aaa
bye
This doesn't seem to work. How do I upload a number of files?
In case the file already exists, it should be overwritten without even
asking..
With a wildcard, you need to use MPUT, and run the script through
ftp -i -s:MyScript
Typical script contents, including making appropriate remote folder
open ftp.mysitename.net
MyUserName
MyPassword
cd /work/myfiles
mput filespec*.*
quit
Details of controlling FTP transfers from a Batch file (includes how to
change remote file permissions): http://www.allenware.com/find?BatchFTP
This StudyPack includes advanced Batch examples to show how to record a
logfile of an FTP session, and to have progress reports shown on-screen
during a long FTP session (with Subroutine using explicit redirection).
For help with FTP, use -h switch
ftp -h
--
William Allen
Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
Batch Reference with examples http://www.allenware.com/icsw/icswref.htm
Header email is rarely checked. Contact us at http://www.allenware.com/
Hi,

Thanks for your help. And how do I make sure the file will be
overwritten?
So the -i will do this, right?

Sandra
William Allen
2005-07-23 08:25:31 UTC
Permalink
"Sandra" wrote in message
...snip
Post by Sandra
Thanks for your help. And how do I make sure the file will be
overwritten?
A remote file is automatically overwritten when a local file that
is PUT or MPUT has the same name as the remote file.
Post by Sandra
So the -i will do this, right?
No. The -i switch is there to prevent prompting for each file that
matches a wildcard in an MPUT or MGET command. Without
the -i switch, you are prompted Yes/No for each file that matches
the wildcard, regardless of whether a same name file would be
overwritten by the transfer command.

See the FTP help for MPUT and MGET, and also check GLOB
(expansion of wildcard metacharacters - normally ON by default).

--
William Allen
Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
Batch Reference with examples http://www.allenware.com/icsw/icswref.htm
Header email is rarely checked. Contact us at http://www.allenware.com/
Continue reading on narkive:
Loading...