FTP Batch File?

Piyono

Storage is cool
Joined
Jan 25, 2002
Messages
599
Location
Toronto
He-e-eyyy... I like what you've done with the place. You guys want me to purplish-blue-ify the favicon to match the new color scheme? Not that there's a full-size icon to match, anymore...
:)

I currently back up a few small documents to a web server manually, using a GUI FTP client. It's fine but I'd got to thinking that it might be possible to write a batch file that would back my files up using XP's command line FTP. I tried but I can't figure out a secure way to pass my user name and password to the server in the batch file. I considered connecting to the server on one line, inserting a pause of a few seconds and then passing the user name and password, each on their own line, in anticipation of the corresponding prompts, but ruled that out because net conditions could change the timing of the prompts.

Anyone have a better way to do this? The goal is to double-click a single file on my dekstop and know that all the backups will be performed.

Thanks,

Piyono
 

timwhit

Hairy Aussie
Joined
Jan 23, 2002
Messages
5,278
Location
Chicago, IL
Maybe a better option would be to find a program that could perform batch FTP commands, rather than writing your own batch file.

I don't know if such a thing exists, but hopefully it would encrypt your password also.
 

Pradeep

Storage? I am Storage!
Joined
Jan 21, 2002
Messages
3,845
Location
Runny glass
He-e-eyyy... I like what you've done with the place. You guys want me to purplish-blue-ify the favicon to match the new color scheme? Not that there's a full-size icon to match, anymore...
:)

I currently back up a few small documents to a web server manually, using a GUI FTP client. It's fine but I'd got to thinking that it might be possible to write a batch file that would back my files up using XP's command line FTP. I tried but I can't figure out a secure way to pass my user name and password to the server in the batch file. I considered connecting to the server on one line, inserting a pause of a few seconds and then passing the user name and password, each on their own line, in anticipation of the corresponding prompts, but ruled that out because net conditions could change the timing of the prompts.

Anyone have a better way to do this? The goal is to double-click a single file on my dekstop and know that all the backups will be performed.

Thanks,

Piyono


Should be able to pass your username/pwd in one line like this:

ftp://username : password@www.ftpsite.com

No spaces next to the colon (had to space them in the post to avoid unintended smiley).
 

Will Rickards

Storage Is My Life
Joined
Jan 23, 2002
Messages
2,012
Location
Here
Website
willrickards.net
We used to use ftp batch files at work to deploy executables to application servers. I believe the username and password had to be in the file itself and you had to use a switch like -p or something.

looking up the command line options in my xp cmd shell gives me:
Code:
FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [-A] [host]

  -v             Suppresses display of remote server responses.
  -n             Suppresses auto-login upon initial connection.
  -i             Turns off interactive prompting during multiple file
                 transfers.
  -d             Enables debugging.
  -g             Disables filename globbing (see GLOB command).
  -s:filename    Specifies a text file containing FTP commands; the
                 commands will automatically run after FTP starts.
  -a             Use any local interface when binding data connection.
  -A             login as anonymous.
  -w:buffersize  Overrides the default transfer buffer size of 4096.
  host           Specifies the host name or IP address of the remote
                 host to connect to.

Notes:
  - mget and mput commands take y/n/q for yes/no/quit.
  - Use Control-C to abort commands.

One of my first google results for "ftp -s" is this MS knowledgebase article

Using FTP Batch Scripts
View products that this article applies to.
Article ID : 96269
Last Review : October 31, 2006
Revision : 3.2
This article was previously published under Q96269
SUMMARY
FTP (file transfer protocol) is a file transfer utility commonly used with UNIX systems.

FTP is capable of using scripts (lists of commands from external files). The following example demonstrates a script that opens a connection to IP address 11.11.11.11, logs on to the host as a guest with the password "guest," uploads the File1 file, and then quits:
open 11.11.11.11
user
guest
guest
put file1
quit
MORE INFORMATION
You must use the -s option for FTP to read this file under Windows. If the previous script was in a file called Test.scr, you can start the script by typing:
ftp -s:test.scr
You can specify the host name in the command line and then use the script to process the login. For example, if you use the following command line
ftp -s:test.scr 11.11.11.11
the script file should read as follows:
user
guest
guest
put file1
quit
However, if the FTP host implements automatic login, this command will not work. To turn off automatic login, use the -n switch in the command line as follows:
ftp -n -s:test.scr 11.11.11.11
 

Piyono

Storage is cool
Joined
Jan 25, 2002
Messages
599
Location
Toronto
Thanks, guys, I'll run with that for a bit and see what I can come up with.

]-[
 
Top