topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday December 13, 2024, 2:14 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: idea connect to a ftp server  (Read 10530 times)

sizzle

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
idea connect to a ftp server
« on: October 04, 2009, 04:31 PM »
I've been searching for a script that would connect to a ftp server (user name and password required) and then transfer multiple files back from the server to the users computer. It seems that there might be something like this out there already. Any ideas?

Thanks

scancode

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 641
  • I will eat Cody someday.
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: idea connect to a ftp server
« Reply #1 on: October 04, 2009, 05:08 PM »
I've been searching for a script that would connect to a ftp server (user name and password required) and then transfer multiple files back from the server to the users computer. It seems that there might be something like this out there already. Any ideas?

Thanks

You can script FTP.exe

echo open ftp.myftpserver.com>script.ftp
echo myusername>>script.ftp
echo mypassword>>script.ftp
echo binary>>script.ftp
echo get file1>>script.ftp
echo get file2>>script.ftp
echo bye>>script.ftp
ftp -s:script.ftp
del script.ftp

sizzle

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
Re: idea connect to a ftp server
« Reply #2 on: October 04, 2009, 08:48 PM »
You can script FTP.exe

echo open ftp.myftpserver.com>script.ftp
[/quote]


Thanks
I'm not sure where to customize my enteries.
I'm guessing replace ftp.myserver.com and myusername  and mypassword with my personal info.
But what about echo binary
and how do I select the specific files that I want to download. Should I replace echo get file1 with the name of the file?ftp
When I replace ftp.myserver.com I get an error message
If you could be a little more specific that would help.
I am new to all this...........obviously.
« Last Edit: October 04, 2009, 08:51 PM by sizzle »

scancode

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 641
  • I will eat Cody someday.
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: idea connect to a ftp server
« Reply #3 on: October 04, 2009, 09:11 PM »
I'm not sure where to customize my enteries.
I'm guessing replace ftp.myserver.com and myusername  and mypassword with my personal info.
But what about echo binary
and how do I select the specific files that I want to download. Should I replace echo get file1 with the name of the file?ftp
When I replace ftp.myserver.com I get an error message
If you could be a little more specific that would help.
I am new to all this...........obviously.

echo open ftp.myftpserver.com>script.ftp
echo myusername>>script.ftp
echo mypassword>>script.ftp
echo binary>>script.ftp
echo get file1>>script.ftp
echo get file2>>script.ftp
echo bye>>script.ftp
ftp -s:script.ftp
del script.ftp

If your files are in different directories, you must use the CD command.
echo get the_directory>>script.ftp

Here's an FTP tutorial to get you started. http://cs.ecs.baylor...torials/ftp/ftp.html

sizzle

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
Re: idea connect to a ftp server
« Reply #4 on: October 04, 2009, 09:37 PM »
OK I placed all the custom info where you indicated in red
and I get an error message that says:
 line text: echo open ftp.sizzlermgt.com>script.ftp
Error: This line does not contain a recognized action.

The program exits after this error message
Am I doing something wrong?

scancode

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 641
  • I will eat Cody someday.
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: idea connect to a ftp server
« Reply #5 on: October 05, 2009, 04:14 AM »
ftp.sizzlermgt.com

I doubt that's the problem.
Can you paste the entire script blanking out the login info?

awopbamboo

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 118
    • View Profile
    • Donate to Member
Re: idea connect to a ftp server
« Reply #6 on: October 05, 2009, 07:52 AM »
Hi Sizzle

Apologies for stepping in here, but I think I know why you're having aproblem running the script provided.

My guess is, you are trying to run the script from scancode in as an AHK script?  But what he has provided you is a script to run as a WINDOWS batch or cmd file, its NOT an AHK script.

You will need to run from the command line, or ideally create a batch file and run that. I have attached it to this message (extract from the zip file).  Open the attached file with NOTEPAD, edit the settings such as server name etc so:
change

ftp.myftpserver.com  to your ftp servername
myusername  to your ftp username
mypassword  to your ftp password

Try that and see if thats any better.


Apologies if I have mis-understood everyone!

J.
_____________________________________________
J.

scancode

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 641
  • I will eat Cody someday.
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: idea connect to a ftp server
« Reply #7 on: October 05, 2009, 09:01 AM »
I think you nailed it, J.

sizzle

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
Re: idea connect to a ftp server
« Reply #8 on: October 05, 2009, 10:29 AM »
Thanks J. and Scancode.
My apologies for not making myself clear that I was interested in doing this in an AHK script.

I tried this with a batch file and there are 2 issues. The first being is that the files I want to transfer are in a different directory on the server. In other words the entire path is ftp://sizzlermgt.com/StoreFiles/
Putting that address in the open cmd. doesn't work. I guess I need a change directory command.

Second to test the bat.file I tried to download a file from the parent directory (ftp.sizzlermgt.com). The file name that is in the bat.file(echo get StoreInfo.pdf>>script.ftp)  and does indeed exist in the parent directory appears on my desktop, but when you open it there is no data in it.

Is there a way that I can step through the bat.file so I can see what the cmd line comments are. The cmd lines executed come up on the screen for a brief instant and it is hard to read what's going on.

Thank you both for your time.

awopbamboo

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 118
    • View Profile
    • Donate to Member
Re: idea connect to a ftp server
« Reply #9 on: October 05, 2009, 10:33 AM »
Add the line:
echo cd StoreFiles after the line that says echo binary>>script.ftp like so....

echo open ftp.myftpserver.com>script.ftp
echo myusername>>script.ftp
echo mypassword>>script.ftp
echo binary>>script.ftp
echo cd StoreFiles
echo get file1>>script.ftp
echo get file2>>script.ftp
echo bye>>script.ftp
ftp -s:script.ftp
del script.ftp


Hopw that makes sense....
_____________________________________________
J.

sizzle

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
Re: idea connect to a ftp server
« Reply #10 on: October 05, 2009, 11:47 AM »
Same result the file that is created on the desktop is empty.

I managed to get a look at what's going on in the DOS window. It appears that the bat.file is connecting to the server and the user is logged in but when the echo binary line executes the message
Aborting any active data connections.... connection closed by remote host appears. Then we get a cmd line that says not connected.

I've tried moving this line down after get file.......I've tried taking it out and it always disconnects after the user is logged in. I know we are connecting to the server and the password is being accepted and the user is logged in, all of these things appear in the DOS window.

Any idea what's going on?

sizzle

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
Re: idea connect to a ftp server
« Reply #11 on: October 05, 2009, 01:46 PM »
OK here's the solution.
the line echo cd StoreFiles needs to be changed to:

echo cd StoreFiles>>script.ftp

What was happening was the script was not changing to the "storefiles" directory and the script was unable to find the specific file to download. Now it changes to the proper directory and downloads the proper files.

Thanks for your help guys.


MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: idea connect to a ftp server
« Reply #12 on: October 05, 2009, 03:39 PM »
Another way to create a batch right off the command prompt is to use copy con filename command.  Then just type in the lines you want "filename" file to contain.  When done, press ^z and you will get the command prompt back. Just avoids all that file append business.  The copy command will do it for you.

It makes it a bit easier to see what you've typed.  Or just using a text editor is probably best.  I usually use EditPadLite and save the file just leaving the editor open.  When I run it and get an error, I can just edit the file and save again until I get it right.  Running the batch just reads it so it doesn't care if EditPadLite already has the file open.

scancode

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 641
  • I will eat Cody someday.
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: idea connect to a ftp server
« Reply #13 on: October 05, 2009, 06:57 PM »
Another way to create a batch right off the command prompt is to use copy con filename command.  Then just type in the lines you want "filename" file to contain.  When done, press ^z and you will get the command prompt back. Just avoids all that file append business.  The copy command will do it for you.

The file appending thing is because I like to keep my scripts in a single file :P
You can also make them in notepad and call ftp.exe -s:script.txt ;)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: idea connect to a ftp server
« Reply #14 on: October 05, 2009, 07:27 PM »
I don't understand.  All I'm saying is if you do copy con filename every line you type will be in "filename" file until you press ^z.  How you execute only a section of a batch file I don't comprehend.