FTP question

P

Paul H

If this is not the appropriate place for this question, please steer me
right.
I hope the following is understandable by one of you batch file Guru's.
I need to automate a process that has been running manually. It goes like
this:

1. Open a DOS window.

2. Change to the folder I want to receive the file into.

3. enter "ftp ftp.blahblahblah.com".

4. When prompted as follows, enter a User ID. The following 4 lines of text
are received, after a .2 second to maybe 10 or more second wait, then
wanting a User ID to be entered.

a) Connected to ftp.blahblahblah.com.
b) 220-Microsoft FTP Service
c) 220 WARNING: Unauthorized [snip] suspected.
c(User <ftp.blahblahblah.com:<none>>:
d) abc (I have entered the User ID "abc".

5. When prompted as follows, enter the password. The following 2 lines of
text are received after a variable length delay:

a)331 Password required for abc.
b)456xyz (I have entered the password "456xyz")

6. Cause the file to be retrieved. This will be prompted for by:

a)2130-WARNING: Unauthorized [snip] suspected.
b)230 User abc logged in.
c)ftp>
d)get MyNewFile.txt (I have entered "get MyNewFile.txt")

7. end the FTP session.



It's been quite a while since I did a DOS batch file, so I need help.
My 1st guess would be:
cd \new-in
echo off
ftp ftp.blahblahblah.com
ftp ftp.blahblah.com
wait for the prompt (somehow watching for specific text)
echo abc
wait for the prompt (somehow watching for specific text)
echo 456xyz
echo get MyNewFile.txt
echo quit
execute a local program to process the file just received.
exit

TIA, Paul
 
P

Paul H

If this is not the appropriate place for this question, please steer me
right. I also put this in the XP General area, because the process will run
on an XP machine for a while. Also, the Vista version had a couple typos I
have fixed.
I hope the following is understandable by one of you batch file Guru's.
I need to automate a process that has been running manually. It goes like
this:

1. Open a DOS window.

2. Change to the folder I want to receive the file into.

3. enter "ftp ftp.blahblahblah.com".

4. When prompted as follows, enter a User ID. The following 4 lines of text
are received, after a .2 second to maybe 10 or more second wait, then
wanting a User ID to be entered.

a) Connected to ftp.blahblahblah.com.
b) 220-Microsoft FTP Service
c) 220 WARNING: Unauthorized [snip] suspected.
c(User <ftp.blahblahblah.com:<none>>:

d) abc (I have entered the User ID "abc".

5. When prompted as follows, enter the password. The following line of
text is received after a variable length delay:

a)331 Password required for abc.

b)456xyz (I have entered the password "456xyz")

6. Cause the file to be retrieved. This will be prompted for by:

a)2130-WARNING: Unauthorized [snip] suspected.
b)230 User abc logged in.
c)ftp>
d)get MyNewFile.txt (I have entered "get MyNewFile.txt")

7. end the FTP session.



It's been quite a while since I did a DOS batch file, so I need help.
My 1st guess would be:
cd \new-in
echo off
ftp ftp.blahblahblah.com
wait for the prompt (somehow watching for specific text)
echo abc
wait for the prompt (somehow watching for specific text)
echo 456xyz
echo get MyNewFile.txt
echo quit
execute a local program to process the file just received.
exit

TIA, Paul
 
S

Synapse Syndrome

Paul H said:
If this is not the appropriate place for this question, please steer me
right.
I hope the following is understandable by one of you batch file Guru's.
I need to automate a process that has been running manually. It goes
like this:

1. Open a DOS window.

2. Change to the folder I want to receive the file into.

3. enter "ftp ftp.blahblahblah.com".

4. When prompted as follows, enter a User ID. The following 4 lines of
text are received, after a .2 second to maybe 10 or more second wait,
then wanting a User ID to be entered.

a) Connected to ftp.blahblahblah.com.
b) 220-Microsoft FTP Service
c) 220 WARNING: Unauthorized [snip] suspected.
c(User <ftp.blahblahblah.com:<none>>:
d) abc (I have entered the User ID "abc".

5. When prompted as follows, enter the password. The following 2 lines
of text are received after a variable length delay:

a)331 Password required for abc.
b)456xyz (I have entered the password "456xyz")

6. Cause the file to be retrieved. This will be prompted for by:

a)2130-WARNING: Unauthorized [snip] suspected.
b)230 User abc logged in.
c)ftp>
d)get MyNewFile.txt (I have entered "get MyNewFile.txt")

7. end the FTP session.



It's been quite a while since I did a DOS batch file, so I need help.
My 1st guess would be:
cd \new-in
echo off
ftp ftp.blahblahblah.com
ftp ftp.blahblah.com
wait for the prompt (somehow watching for specific text)
echo abc
wait for the prompt (somehow watching for specific text)
echo 456xyz
echo get MyNewFile.txt
echo quit
execute a local program to process the file just received.
exit


I use batch scripts to copy files to FTP and cloud storage, but using
virtual drive letters provided by WebDrive or Gladinet. I've not used the
FTP console client. I'd ask in the server newsgroup where Pegasus MVP will
probably help you out.

ss.
 
T

the wharf rat

I hope the following is understandable by one of you batch file Guru's.
I need to automate a process that has been running manually. It goes like
this:

There are some things it's not worth fighting with batch files
over. You could use visual basic but frankly VB's a pain. Luckily
perl runs just fine on windows. This is all you'd need.

use Net::FTP;

$ftp = Net::FTP->new($host) ||
(die "Cannot open FTP session to $host\n");
$ftp->login($user,$pass) ||
(die "Login to $host as $user failed.\n");
$ftp->binary();
$ftp->get($pathtoremotefile,$pathtolocalfile) ||
(die "Put of $pathtolocalfile to $host failed.\n") ;
$ftp->quit;

Perl's much easier to learn than VB is so if you've never worked in it
this would be a good opportunity :)
 
B

+Bob+

There are some things it's not worth fighting with batch files
over. You could use visual basic but frankly VB's a pain. Luckily
perl runs just fine on windows. This is all you'd need.

use Net::FTP;

$ftp = Net::FTP->new($host) ||
(die "Cannot open FTP session to $host\n");
$ftp->login($user,$pass) ||
(die "Login to $host as $user failed.\n");
$ftp->binary();
$ftp->get($pathtoremotefile,$pathtolocalfile) ||
(die "Put of $pathtolocalfile to $host failed.\n") ;
$ftp->quit;

Perl's much easier to learn than VB is so if you've never worked in it
this would be a good opportunity :)

I'd have to disagree with you in a major way there, Wharf. Perl is
convoluted, un-intuitive, cryptic, and difficult. Not that I don't
like it :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top