Solved

MS DOS FTP Batch File question

Posted on 2009-05-14
13
731 Views
Last Modified: 2013-12-09
Hello, I am trying to run a batch file that reads in a .txt file and FTP's.  Here is what I got:

.bat file:

ftp -s:\FTP\folder1\folder2\thefile.txt  something.something.com

.txt file:

loginName
passWord
Get 'the file that is being ftp'd'
bye

If I start the .bat file it seems to read the text file but MS DOS screen just flashes by really fast then closes. it doesn't ftp anything
0
Comment
Question by:mk09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 2

Accepted Solution

by:
Manoj_a earned 50 total points
ID: 24391503
You can try this in the script file

open something.something.com
username
password
cd <>
get file.txt
bye
0
 
LVL 8

Assisted Solution

by:97WideGlide
97WideGlide earned 50 total points
ID: 24391601
Try putting "pause" at the end of your bat file so that you can see what error you are getting.
0
 
LVL 96

Assisted Solution

by:Lee W, MVP
Lee W, MVP earned 25 total points
ID: 24391614
Either a pause, or don't double click it - Open a command prompt and run it from the command prompt.  That way, the Command Prompt window doesn't disappear and you can SEE the error message.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:nettek0300
ID: 24391649
You should also be able to add " > c:\directory\logfile.log" and the output of any errors would go to a text file in the specified directory.
0
 
LVL 28

Expert Comment

by:lesouef
ID: 24393004
your script file is wrong, it should include commands except for the passwd:
example
> ftp -s:parameter.txt
where parameter is:
open site
user loginName
passWord
Get path/file
bye
-------------
and check manually all this is correct, path, file, etc...
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 24395234
It's more common to use:
  ftp -n -s:parameter.txt
with paramter.txt:
  open SITE
  login LOGIN PWD
  get FILE
  bye



0
 
LVL 28

Expert Comment

by:lesouef
ID: 24395403
not sure putting the passwd on the same line as the user works with all servers...
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 24395423
The other way is to use the pass keyword:
login LOGIN
pass PWD

0
 
LVL 28

Expert Comment

by:lesouef
ID: 24395645
no, same, on some servers, it takes the "pass PWD" as the complete password, so you have to test it before.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 24395692
This never happened to me ... In non-interactive mode, this is not a correct behaviour. All inputs have to be prefixed by a command.
0
 
LVL 28

Expert Comment

by:lesouef
ID: 24396376
I need to search in my deep disk where I did that, but I am sure I had to do it.
Yes, got it, that was the ftp server of an AS400, and even user was not to be specified:
so the answer file was
open [ip]
[user]
[passwd]
...
so always worth to test...
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 24397154
We have always used that keywords, even with AS/400. I cross-checked that just at the moment, our scripts working (!) do allow for the login keyword with username and password. Maybe it depends on the FTP packet version on AS/400, but I never saw anything else, with different UNIX machines.

Nevertheless, AS/400 is something awkward in obeying standards ... And of course FTP scripts need to be tested in all cases - because of the incompatibility issues and restricted command sets.
0
 

Author Comment

by:mk09
ID: 24397516
Hey guys, thanks for all the tips.

What I needed to do was redirect the .bat file as I was getting a UNC error.  The code itself was fine besides that.  I had a pause in the .txt file to check for errors, but it needed to be in the .bat file.

so basically

.bat file:
:s
ftp -s:\FTP\folder1\folder2\thefile.txt  something.something.com
pause

.txt file:
loginName
passWord
Get 'the file that is being ftp'd'
bye


Is what ended up working for me.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question