Solved

MS DOS FTP Batch File question

Posted on 2009-05-14
13
712 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
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…

778 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