MS DOS FTP Batch File question

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
mk09Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Manoj_aConnect With a Mentor Commented:
You can try this in the script file

open something.something.com
username
password
cd <>
get file.txt
bye
0
 
97WideGlideConnect With a Mentor Commented:
Try putting "pause" at the end of your bat file so that you can see what error you are getting.
0
 
Lee W, MVPConnect With a Mentor Technology and Business Process AdvisorCommented:
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 
nettek0300Commented:
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
 
lesouefCommented:
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
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
It's more common to use:
  ftp -n -s:parameter.txt
with paramter.txt:
  open SITE
  login LOGIN PWD
  get FILE
  bye



0
 
lesouefCommented:
not sure putting the passwd on the same line as the user works with all servers...
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
The other way is to use the pass keyword:
login LOGIN
pass PWD

0
 
lesouefCommented:
no, same, on some servers, it takes the "pass PWD" as the complete password, so you have to test it before.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
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
 
lesouefCommented:
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
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
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
 
mk09Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.