Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS DOS FTP Batch File question

Posted on 2009-05-14
13
Medium Priority
?
741 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 200 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 200 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 100 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 71

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 71

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 71

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 71

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

Independent Software Vendors: 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

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Many of the companies I’ve worked with have embraced cloud solutions due to their desire to “get out of the datacenter business.” The ability to achieve better security and availability, and the speed with which they are able to deploy, is far grea…
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…
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

715 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