Looking for a one-line command (or a batch file) that uploads a specific file to a specific ftp server.
August 25, 2004 2:31 PM Subscribe
I'm looking for a one-line command (or a batch file) that uploads a specific file to a specific ftp server.
Via #mefi user quiet:
cURL is your friend. You didn't say which OS, so get the binary you need. Now to upload a file, just use the -T option.
So something like:
curl -T MyFileToUpload.txt ftp://myusername:mypassword@ftp.myhost.com/directory/
You can put a -v option to check that everything is working the first time.
posted by cmonkey at 2:52 PM on August 25, 2004
cURL is your friend. You didn't say which OS, so get the binary you need. Now to upload a file, just use the -T option.
So something like:
curl -T MyFileToUpload.txt ftp://myusername:mypassword@ftp.myhost.com/directory/
You can put a -v option to check that everything is working the first time.
posted by cmonkey at 2:52 PM on August 25, 2004
ftp will let you do it, but I don't think it's entirely obvious how unless you have a bit of experience with scripting languages. In bash, under unix, here's what I do:
This works fine under cygwin as well. Just make sure you have the cygwin ftp binary installed.
If what you have to do is a bit complex, or there's some other reason to do things in a single batch like this, it's the best way to go. For a single file, curl, as mentioned above is a lot simpler.
posted by mragreeable at 3:55 PM on August 25, 2004
ftp -niv << EOF
user adam <password>
cd /home/frank
put franks_file
EOF
This works fine under cygwin as well. Just make sure you have the cygwin ftp binary installed.
If what you have to do is a bit complex, or there's some other reason to do things in a single batch like this, it's the best way to go. For a single file, curl, as mentioned above is a lot simpler.
posted by mragreeable at 3:55 PM on August 25, 2004
Small correction - that first line should be :
posted by mragreeable at 3:58 PM on August 25, 2004
ftp -niv myhost.com << EOF
posted by mragreeable at 3:58 PM on August 25, 2004
That's pretty neat, actually; means you can have a .bat file like this:
@echo off
curl -T %1 ftp://myusername:mypassword@ftp.myhost.com/directory/
and drag-n-drop single files onto it. Could probably make it support multiple files, too, if I could be bothered right now.
posted by reklaw at 3:58 PM on August 25, 2004
@echo off
curl -T %1 ftp://myusername:mypassword@ftp.myhost.com/directory/
and drag-n-drop single files onto it. Could probably make it support multiple files, too, if I could be bothered right now.
posted by reklaw at 3:58 PM on August 25, 2004
OK, so I can never resist writing frivolous batch files.
@echo off
:loop
if %1=="" goto end
echo uploading %1...
curl -T %1 ftp://myusername:mypassword@ftp.myhost.com/directory/
shift
goto loop
:end
echo done.
pause
will upload any file you drag onto the batch file (probably). I've wanted something like this for a while, so I'm glad I finally got round to figuring it out.
posted by reklaw at 4:25 PM on August 25, 2004
@echo off
:loop
if %1=="" goto end
echo uploading %1...
curl -T %1 ftp://myusername:mypassword@ftp.myhost.com/directory/
shift
goto loop
:end
echo done.
pause
will upload any file you drag onto the batch file (probably). I've wanted something like this for a while, so I'm glad I finally got round to figuring it out.
posted by reklaw at 4:25 PM on August 25, 2004
Hm, on that note, how'd you do that in Mac OS X? I would know how to make a droplet (batch script you can drag stuff on) in applescript, but not a shell script.
Any ideas?
posted by jragon at 5:06 PM on August 25, 2004
Any ideas?
posted by jragon at 5:06 PM on August 25, 2004
Not to hijack, but what if I wantd to do this with multiple files/ folders under one folder but only if the file has been updated in the last 24 hours? Not looking for a written script, just what I should be using to do this efficiently.
posted by yerfatma at 7:06 PM on August 25, 2004
posted by yerfatma at 7:06 PM on August 25, 2004
you should look into maybe scp as well.
posted by angry modem at 7:53 PM on August 25, 2004
posted by angry modem at 7:53 PM on August 25, 2004
This thread is closed to new comments.
posted by seanyboy at 2:52 PM on August 25, 2004