Solved

MS DOS FTP Batch File question

Posted on 2009-05-14
13
694 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
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 95

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
 
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 68

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 68

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 68

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 68

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
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…
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, fr…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now