Solved

MS DOS FTP Batch File question

Posted on 2009-05-14
13
719 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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 69

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 69

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 69

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 69

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Cloud file services can fill many different roles for your business. Often, the use of cloud file services begins with employees using consumer products, like Dropbox, to share files with customers and each other. While sync-and-share can be an effe…
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.
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…
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…

789 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