PDA

View Full Version : Uploading to ftp




thriftinkid
Apr 10, 2008, 07:26 PM
Hey guys,

I am trying to upload the contents of a folder to my ftp site. I tried using the upload to ftp action, and ftp transfer actions in automator. I they either don't upload the files, or they upload the first file, and then an error pops up, thus stopping my script. I then tried to write an applescript using my ftp application "cuteftp". The problem is the software has a tendency to lock up during transfers sometimes, and I want to make sure the connection is solid everytime. Is there any other applescript I can write to connect to my ftp server to make the file transfers? Somehow maybe using Mac OS Internet connect or something? I'm new to writing code, so please be patient with me. I'm not as smart as you guys. Thanks.



yeroen
Apr 10, 2008, 08:18 PM
Can you ftp from the terminal command-line?

If you try it, what do you see?

psingh01
Apr 10, 2008, 10:11 PM
ncftp is another command that I've used to send entire directories to my host from a linux box. I don't think the regular ftp program recursively goes through all child directories, but I could be wrong.

It doesn't seem to be on my Mac by default, but this is where you can download for osx.

http://www.ncftp.com/download/

The two commands you need to look at are: ncftpget and ncftpput

http://www.devdaily.com/unix/man/man1/ncftpput.1.shtml

After getting this installed you would go to the terminal and type a command like:

ncftpput -u bob -p bobspasswd -R ftp.somehost.com /remote/path /local/dir/to/send

thriftinkid
Apr 11, 2008, 09:15 AM
Can you ftp from the terminal command-line?

If you try it, what do you see?

I looked at the applescript dictionary for ftp commands, but didn't find any. It has a command to run a UNIX shell script or command, but that is way over my head. I have no idea where to start.

ncftp is another command that I've used to send entire directories to my host from a linux box. I don't think the regular ftp program recursively goes through all child directories, but I could be wrong.

It doesn't seem to be on my Mac by default, but this is where you can download for osx.

http://www.ncftp.com/download/

The two commands you need to look at are: ncftpget and ncftpput

http://www.devdaily.com/unix/man/man1/ncftpput.1.shtml

After getting this installed you would go to the terminal and type a command like:

ncftpput -u bob -p bobspasswd -R ftp.somehost.com /remote/path /local/dir/to/send

I downloaded your suggested link, but I'm having a hard time even installing the program. When I say I'm new to writing code, imagine you are talking to a three year old, and you are drawing things out in crayon. : )

psingh01
Apr 11, 2008, 10:41 AM
I downloaded your suggested link, but I'm having a hard time even installing the program. When I say I'm new to writing code, imagine you are talking to a three year old, and you are drawing things out in crayon. : )

Ok :) On the link that I sent posted, you just need to install the client for OSX. Here are the direct links to the installers. If you have an intel mac choose the first one, if you have a ppc mac choose the second.

ftp://ftp.ncftp.com/ncftp/binaries/ncftp-3.2.1-macosx10.4-intel.dmg
ftp://ftp.ncftp.com/ncftp/binaries/ncftp-3.2.1-macosx10.4-ppc.dmg

Once you download it just install it like you would any other program. Double click the dmg file to mount the image (this might happen automatically when you are done downloading the file). Then go in that folder and double click the "NcFTP 3.2.1.pkg" to run the installer. Just click through the dialog until it is done installing.

Now to run the program you have to go to the Terminal app in Applications/Utilities folder.

In the terminal type:

ncftpput -u USER -p PASSWORD -R HOST /remote/dir/path /local/dir/path

You just have to replace USER, PASSWORD, HOST with your username, password and hostname of the server you will upload to.

For /remote/dir/path replace that with the directory path on the server where you want to upload your files. For /local/dir/path just put the path to the directory you want to upload.

As an example. On my laptop my username is psingh01 and I want to upload the directory "VacationPics" from my Desktop to my account on ftp.apple.com. On ftp.apple.com I have the username "ps123" and the password "secretpass". The directory on ftp.apple.com that I will upload to is "/home/ps123/vacpics".

The command I would type would look like this:

ncftpput -u ps123 -p secretpass -R ftp.apple.com /home/ps123/vacpics /Users/psingh01/Desktop/VacationPics

Press Enter and you should see a little text message of it uploading. Or an error message if something went wrong.

For more information on how ncftpput works, enter "man ncftpput" in the Terminal and it will display the help text. Use the arrows to move up and down the help page. Then type q to exit/quit the help page viewer.

lazydog
Apr 11, 2008, 11:08 AM
Hey guys,

I am trying to upload the contents of a folder to my ftp site. I tried using the upload to ftp action, and ftp transfer actions in automator. I they either don't upload the files, or they upload the first file, and then an error pops up, thus stopping my script. I then tried to write an applescript using my ftp application "cuteftp". The problem is the software has a tendency to lock up during transfers sometimes, and I want to make sure the connection is solid everytime. Is there any other applescript I can write to connect to my ftp server to make the file transfers? Somehow maybe using Mac OS Internet connect or something? I'm new to writing code, so please be patient with me. I'm not as smart as you guys. Thanks.

You might try ftping from the command line to see if it's an ftp connection problem you're having in general rather than an automator one. If it is a connection problem then switching mode from active to passive… or passive to active… may solve your problem.

b e n

thriftinkid
Apr 11, 2008, 11:26 AM
Ok :) On the link that I sent posted, you just need to install the client for OSX. Here are the direct links to the installers. If you have an intel mac choose the first one, if you have a ppc mac choose the second.

ftp://ftp.ncftp.com/ncftp/binaries/ncftp-3.2.1-macosx10.4-intel.dmg
ftp://ftp.ncftp.com/ncftp/binaries/ncftp-3.2.1-macosx10.4-ppc.dmg

Once you download it just install it like you would any other program. Double click the dmg file to mount the image (this might happen automatically when you are done downloading the file). Then go in that folder and double click the "NcFTP 3.2.1.pkg" to run the installer. Just click through the dialog until it is done installing.

Now to run the program you have to go to the Terminal app in Applications/Utilities folder.

In the terminal type:

ncftpput -u USER -p PASSWORD -R HOST /remote/dir/path /local/dir/path

You just have to replace USER, PASSWORD, HOST with your username, password and hostname of the server you will upload to.

For /remote/dir/path replace that with the directory path on the server where you want to upload your files. For /local/dir/path just put the path to the directory you want to upload.

As an example. On my laptop my username is psingh01 and I want to upload the directory "VacationPics" from my Desktop to my account on ftp.apple.com. On ftp.apple.com I have the username "ps123" and the password "secretpass". The directory on ftp.apple.com that I will upload to is "/home/ps123/vacpics".

The command I would type would look like this:

ncftpput -u ps123 -p secretpass -R ftp.apple.com /home/ps123/vacpics /Users/psingh01/Desktop/VacationPics

Press Enter and you should see a little text message of it uploading. Or an error message if something went wrong.

For more information on how ncftpput works, enter "man ncftpput" in the Terminal and it will display the help text. Use the arrows to move up and down the help page. Then type q to exit/quit the help page viewer.

Thanks so much man. You just solved my last problem in this script im writing. Your cooler then jesus with a mohawk.

Thanks so much man. You just solved my last problem in this script im writing. Your cooler then jesus with a mohawk.

Actually there is one more thing. I just double checked my ftp server and realized it uploaded the the entire local folder. (folder included) Is there any way the script can look inside the folder and just upload any files inside?

You might try ftping from the command line to see if it's an ftp connection problem you're having in general rather than an automator one. If it is a connection problem then switching mode from active to passive… or passive to active… may solve your problem.

b e n

It's not a ftp problem, My application "cuteftp" is working just fine right now with the same login info.

Actually there is one more thing. I just double checked my ftp server and realized it uploaded the the entire local folder. (folder included) Is there any way the script can look inside the folder and just upload any files inside?

Also, upon running the same script with more then one file in the folder, the terminal shows the first file in the folder being completely uploaded, it times out and I get the following error:

ncftpput /Users/John/Desktop/Finished: could not send file to remote host.

When I look in the ftp folder it showed it was uploading to, the file isn't there? Any ideas?

Also, upon running the same script with more then one file in the folder, the terminal shows the first file in the folder being completely uploaded, it times out and I get the following error:

ncftpput /Users/John/Desktop/Finished: could not send file to remote host.

When I look in the ftp folder it showed it was uploading to, the file isn't there? Any ideas?

The Terminal Said it couldn't read the reply from control connection.

psingh01
Apr 11, 2008, 01:56 PM
It's not a ftp problem, My application "cuteftp" is working just fine right now with the same login info.


This is simple, just put a * at the end of your local path like this:

ncftpput -u ps123 -p secretpass -R ftp.apple.com /home/ps123/vacpics /Users/psingh01/Desktop/VacationPics/*


It will just look for contents inside VacationPics instead of uploading the folder VacationPics.


Not sure about the other things. Try it on another server if you have access to it. It is possible that there is a firewall issue that is preventing your client from communicating with the server correctly. Which is probably the same issue you wrote about in the original post. I would also suggest just uploading one file at a time and see if that works with the command. If that works fine then your script might have to lookup filenames first, then call that command repeatedly for each file.

One last thing. If you directory path has spaces in the name, then you must quotes around the file path or else the command will get confused with what is the correct filename. So if instead of VacationPics for the folder name, it was Vacation Pics, then you'll have to write the command like this:

ncftpput -u ps123 -p secretpass -R ftp.apple.com /home/ps123/vacpics "/Users/psingh01/Desktop/Vacation Pics/*"

This is true of all commands you run in the terminal, not just ncftpput. They use blank spaces to separate the different inputs.

thriftinkid
Apr 11, 2008, 02:13 PM
This is simple, just put a * at the end of your local path like this:

ncftpput -u ps123 -p secretpass -R ftp.apple.com /home/ps123/vacpics /Users/psingh01/Desktop/VacationPics/*


It will just look for contents inside VacationPics instead of uploading the folder VacationPics.


Not sure about the other things. Try it on another server if you have access to it. It is possible that there is a firewall issue that is preventing your client from communicating with the server correctly. Which is probably the same issue you wrote about in the original post. I would also suggest just uploading one file at a time and see if that works with the command. If that works fine then your script might have to lookup filenames first, then call that command repeatedly for each file.

One last thing. If you directory path has spaces in the name, then you must quotes around the file path or else the command will get confused with what is the correct filename. So if instead of VacationPics for the folder name, it was Vacation Pics, then you'll have to write the command like this:

ncftpput -u ps123 -p secretpass -R ftp.apple.com /home/ps123/vacpics "/Users/psingh01/Desktop/Vacation Pics/*"

This is true of all commands you run in the terminal, not just ncftpput. They use blank spaces to separate the different inputs.

I added the (*) and none of my alias's have space in them, so I will try at home, and if that doesn't work, then I guess it's back to the drawing board. Im writing a script with an ftp program called cyberduck. I'll see if that work too.Let me know if you have any other suggestions. Thanks again for all your help.

larswik
Apr 13, 2008, 01:46 AM
I too was looking last year for FTP uploading and programming in JAVA. I finally downloaded Transmit that came with plug ins for Automator. I can have it upload to one site and when it finishes it starts on the next site. When it is all done it emails me letting me know that it finished.

-Lars