We help IT Professionals succeed at work.

MS DOS FTP BATCH File

Hi,

I have two MS DOS Batch files "FTSE" and "Lehmans" which are in my shared folder at work in G:\Shared\Fixed Income\Sovereign\Mark\Scheduled Tasks. The Lehmans batch file run perfectly. The FTSE file which is pretty much identical does not, I have pasued the DOS screen and see the following error message "Error opening script file txtFTSE.scp."

I have copied the text for both batch files & text files (bottom of post). Like I say the Lehman file works pefectly but the FTSE one does not. I have double checked the password, username & address but cannot find my error.

Any help would be great!

Thanks

My Batch files

FTSE

G:
G:\Shared\Fixed Income\Sovereign\Mark\Scheduled Tasks

ftp -s:txtFTSE.scp data.ftse.com

Lehmans

G:
G:\Shared\Fixed Income\Sovereign\Mark\Scheduled Tasks

ftp -s:txtLehman.scp indexftp.barcap.com

Text Files

FTSE

Username
Password

prompt n

cd data
cd gilts
cd gilts_constituents

get BGCO1406.csv "G:\Shared\Fixed Income\Sovereign\Mark\Scheduled Tasks\BGCO1406.csv" overwrite  

quit

Lehmans

Username
Password

prompt n

cd point
cd download

mget *_TAPLATRI_*_Global_Barcap_HY_Index.csv "G:\Shared\Fixed Income\Sovereign\Mark\FTP\Leh.csv" overwrite

quit
Comment
Watch Question

Most Valuable Expert 2013
Top Expert 2013

Commented:
Is the full name of the "FTSE" text file actually " txtFTSE.scp" ?
wmp

Author

Commented:
Hi woolmilkporc,

The full name of the text file is txtFTSE and the other file is called txtLehman. Really cant see a difference between the two!

Thanks
Most Valuable Expert 2013
Top Expert 2013

Commented:
... and the extension ".scp" ?
 

Author

Commented:
No just txtFTSE. I have just tried to run the code again and changed the batch file to "ftp -s:txtFTSE data.ftse.com" (without the .scp) and the error message jsut said Error opening scripting file txtFTSE.

Commented:
Yes it does seem to be pointing to the script not being found.  Two suggestions:

1. Start a cmd.exe prompt.  CD /d "G:\Shared\Fixed Income\Sovereign\Mark\Scheduled Tasks"
dir txt*.*

to check the filename is exactly right.

Second option is to use a different technique for the ftp scripts, have a look at the options I have in my page here, in particular the "method 3" version keeping it all in the batch file which simplifies things IMO.

http://scripts.dragon-it.co.uk/links/batch-ftp-scripting
Most Valuable Expert 2013
Top Expert 2013

Commented:
Please double check the filenames!
Maybe you suppressed the displaying of "known" extensions?
The files must be named as they appear in the batch files, literally.

Commented:
I suspect the file extension is possibly .txt but hidden when you look in explorer...

Steve
Commented:
Sorry cross posting there!  I would look at the all in one file method too though, for you it would be something like this:

@echo off
(echo open data.ftse.com
echo user Username
echo Password
echo prompt n
echo cd data
echo cd gilts
echo cd gilts_constituents
echo get BGCO1406.csv "G:\Shared\Fixed Income\Sovereign\Mark\Scheduled Tasks\BGCO1406.csv" overwrite  
echo quit
) | ftp -n -i

  Steve

Author

Commented:
Hi dragon-it,

I have just copied the code above and it kinda works (I ve probably done something wrong). I changed the username to my username but is there a way to stop it asking me for my password as I require this task to run in the morning before I get into work?

Thanks

Author

Commented:
One other thing I have noticed is after entering my password it says invalid  command and then interactive mode is on but it does retrieve the file.

thanks again
Most Valuable Expert 2013
Top Expert 2013
Commented:
@echo off
(echo open data.ftse.com
echo user Username Password
echo prompt n
echo cd data
echo cd gilts
echo cd gilts_constituents
echo get BGCO1406.csv "G:\Shared\Fixed Income\Sovereign\Mark\Scheduled Tasks\BGCO1406.csv" overwrite  
echo quit
) | ftp -n -i

Commented:
Hmm, are there any special characters in your password such as & ^()%" etc.  If so might be an issue. As long as you put the password on the next line (not the word password followed by password, just the pasword) and make sure there are no spaces at the end of the lines as sometimes EE appends spaces when you copy from the page.,

You could check the script it is making using notepad instead:

(echo open data.ftse.com
echo user Username
echo Password
echo prompt n
echo cd data
echo cd gilts
echo cd gilts_constituents
echo get BGCO1406.csv "G:\Shared\Fixed Income\Sovereign\Mark\Scheduled Tasks\BGCO1406.csv" overwrite
echo quit
) > x.txt
notepad x.txt



 By all means go back to the script in a seperate file way.  From the same dir check the filename or from that dir do notepad txtFTSE.scp and paste in the text of your script.


Steve

Author

Commented:
Thanks very much guys for your help everything works perfectly now!

Commented:
No problem.  Did you need the password on the same line as the username then in the end.  Each server I have used requires it on a different line but maybe this one is different?

Steve

Author

Commented:
Yes dargon I just did the following "echo user Username Password". I have to admit I have no knowledge of MS DOS so did not even know where to start! But thanks again for your help

Mark

Commented:
I'll make a note of that then for future ref.  thanks Steve