mcs26
asked on
MS DOS Batch file copy file from FTP Site
Hi,
I have no knowledge of MS DOS. However I have copied a Batch file & text file (both below) and tried adjusting it to what I require, which is simply to copy a file from an FTP site to my works G: drive. The DOS screen flicks up but does nothing. Also could someone please explain the first two lines of the Batch file?
Batch File
G:
G:\Shared\Fixed Income\Sovereign\Mark\Sche duled Tasks
ftp -s:txtFTSE.scp data.ftse.com
txtFTSE file
username
password
prompt n
cd data/gilts/gilts_constitue nts
get BGCO1904.csv "G:\Shared\Fixed Income\Sovereign\Mark\FTP\ BGCO1904.c sv" overwrite
quit
Many thanks,
Mark
I have no knowledge of MS DOS. However I have copied a Batch file & text file (both below) and tried adjusting it to what I require, which is simply to copy a file from an FTP site to my works G: drive. The DOS screen flicks up but does nothing. Also could someone please explain the first two lines of the Batch file?
Batch File
G:
G:\Shared\Fixed Income\Sovereign\Mark\Sche
ftp -s:txtFTSE.scp data.ftse.com
txtFTSE file
username
password
prompt n
cd data/gilts/gilts_constitue
get BGCO1904.csv "G:\Shared\Fixed Income\Sovereign\Mark\FTP\
quit
Many thanks,
Mark
the first line switches to the "G:" drive.
The second line should probably read cd G:\Shared\Fixed Income\Sovereign\Mark\Sche duled Tasks which will switch to the specified directory.
The third runs the ftp command with the txtfile as input using data.ftse.com and the site to ftp to.
In the textfile
first line username
second line passowrd
third line tell the ftp programs to not confirm your choices(dont prompt you)
fourth lin changes to the specified directory
fifth lines grabs the file
sixth lines quits
to troubleshoot from within windows go to start then run and type cmd then enter
that will open a command prompt
run your batch file
it should output errors from you program post them here if they dont make sense to you.
The second line should probably read cd G:\Shared\Fixed Income\Sovereign\Mark\Sche
The third runs the ftp command with the txtfile as input using data.ftse.com and the site to ftp to.
In the textfile
first line username
second line passowrd
third line tell the ftp programs to not confirm your choices(dont prompt you)
fourth lin changes to the specified directory
fifth lines grabs the file
sixth lines quits
to troubleshoot from within windows go to start then run and type cmd then enter
that will open a command prompt
run your batch file
it should output errors from you program post them here if they dont make sense to you.
Hi mcs26,
Change to G drive
Execute: ftp to data.ftse.com and the run script (list of ftp commands) (G:\) txtFTSE.scp
Thanks
Pine
Change to G drive
Execute: ftp to data.ftse.com and the run script (list of ftp commands) (G:\) txtFTSE.scp
Thanks
Pine
ASKER
Thanks SirBounty for replying. I have just changed my files to what you said it still however does not copy the file from the FTP site. It says error opening script file G:\Shared\Fixed
So I am guessing it does not like the space in the folder name. Only thing is I cannot change the folder name as I do not have permissions. Any ideas?
Thanks again
Mark
So I am guessing it does not like the space in the folder name. Only thing is I cannot change the folder name as I do not have permissions. Any ideas?
Thanks again
Mark
Is the script located here: G:\Shared\Fixed Income\Sovereign\Mark\Sche duled Tasks?
If so, then you need to ensure that entire path is enclosed in quotes (as in my example above).
Some internal commands will work without them, but ftp will not. The outer quotes are needed since Fixed Income has a space in between it...
Try that and let me know.
If so, then you need to ensure that entire path is enclosed in quotes (as in my example above).
Some internal commands will work without them, but ftp will not. The outer quotes are needed since Fixed Income has a space in between it...
Try that and let me know.
ASKER
Yeah the script is located in G:\Shared\Fixed Income\Sovereign\Mark\Sche duled Tasks. I have quotes around that in the script file not the batch file though.
Still no luck though. My script file looks like this,
lcd "G:\Shared\Fixed Income\Sovereign\Mark\Sche duled Tasks\"
open data.ftse.com
username
password
prompt n
cd data/gilts/gilts_constitue nts
get BGCO1904.csv "G:\Shared\Fixed Income\Sovereign\Mark\FTP\ BGCO1904.c sv" overwrite
quit
Still no luck though. My script file looks like this,
lcd "G:\Shared\Fixed Income\Sovereign\Mark\Sche
open data.ftse.com
username
password
prompt n
cd data/gilts/gilts_constitue
get BGCO1904.csv "G:\Shared\Fixed Income\Sovereign\Mark\FTP\
quit
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Whoops, when I last looked nobody had commented. I went to make some tea, rattled out an answer, hit the Submit button, and it now looks like I have plagiarised and/or reiterated comments made while I was making tea and typing as fast as I could. Sorry ;-)
No worries here Bill. ;^)
Enjoy your tea.
Enjoy your tea.
ASKER
Hi Bill & SirBounty,
thanks for the explantion!
My batch file looks like the line below but still no luck. I am going to e-mail the data provider becuase I cannot really what is wrong?
@ftp -s: "G:\Shared\Fixed Income\Sovereign\Mark\Sche duled Tasks\txtFTSE.scp"
thanks for the explantion!
My batch file looks like the line below but still no luck. I am going to e-mail the data provider becuase I cannot really what is wrong?
@ftp -s: "G:\Shared\Fixed Income\Sovereign\Mark\Sche
ASKER
The error message is still saying "Error opening script file G:\Shared\Fixed Income\Sovereign\Mark\Sche duled Tasks\txtFTSE.scp."
try removing that space after s:...should read:
@ftp -s:"G:\Shared\Fixed Income\Sovereign\Mark\Sche duled Tasks\txtFTSE.scp"
Failing that, you can try with this slight modification:
@cd /d "G:\Shared\Fixed Income\Sovereign\Mark\Sche duled Tasks\txtFTSE.scp"
@ftp -s:txtFTSE.scp
@ftp -s:"G:\Shared\Fixed Income\Sovereign\Mark\Sche
Failing that, you can try with this slight modification:
@cd /d "G:\Shared\Fixed Income\Sovereign\Mark\Sche
@ftp -s:txtFTSE.scp
You're certain that the file exists as txtFTSE.scp?
ASKER
Yeah the file exists, have doubled checked it. Still no luck though.
Check for line breaks in the *.SCP file. If viewing it in Windows Notepad with word-wrap on it may have created a new line like this:
@cd /d "G:\Shared\Fixed Income\Sovereign\Mark\Sche duled
Tasks\txtFTSE.scp"
instead of this:
@cd /d "G:\Shared\Fixed Income\Sovereign\Mark\Sche duled Tasks\txtFTSE.scp"
Copy and paste them both to Notepad and uncheck word-wrap to see.
@cd /d "G:\Shared\Fixed Income\Sovereign\Mark\Sche
Tasks\txtFTSE.scp"
instead of this:
@cd /d "G:\Shared\Fixed Income\Sovereign\Mark\Sche
Copy and paste them both to Notepad and uncheck word-wrap to see.
ASKER
Hi Bill,
Just opened the file and it already has word-wrap unchecked, otherwise like you with it on it does create a new line.
Thanks,
Just opened the file and it already has word-wrap unchecked, otherwise like you with it on it does create a new line.
Thanks,
Hmm - let's try depending on 8.3 conversion then (somewhat presumptuous, but worth a shot)
Spaces should no longer be a factor...
Batch file:
@ftp -s:G:\Shared\FixedI~1\Sove reign\Mark \Schedu~1\ txtFTSE.sc p
Spaces should no longer be a factor...
Batch file:
@ftp -s:G:\Shared\FixedI~1\Sove
lcd G:\Shared\FixedI~1\Sovereign\Mark\FTP
open data.ftse.com
username
password
prompt n
cd data/gilts/gilts_constituents
get BGCO1904.csv overwrite
quit
Are you just fetching one file, and the same file, on a regular basis?
If so, you can possibly avoid all the messing around by using a simpler standalone program file named "URL2File":
http://www.chami.com/free/url2file_wincon.html
It is part of the "HTML-Kit Tools" package:
http://www.chami.com/
Under the "Download / Install" section of the "/url2file_wincon.html" page you will see the links for an Installer version and a ZIP file containing the standalone files (URL2FILE.EXE and Readme.txt). I suggest just using the standalone EXE.
Usage is show a bit further down the download page and there is another "Tip" page showing usage in a batch file:
http://www.chami.com/tips/windows/062598W.html
I prefer this for simple single file fetching to FTP.EXE, but you need to specify the FTP Protocol, eg. target URL, eg:
ftp://data.ftse.com/data/gilts/gilts_constituents/BGCO1904.csv
If so, you can possibly avoid all the messing around by using a simpler standalone program file named "URL2File":
http://www.chami.com/free/url2file_wincon.html
It is part of the "HTML-Kit Tools" package:
http://www.chami.com/
Under the "Download / Install" section of the "/url2file_wincon.html" page you will see the links for an Installer version and a ZIP file containing the standalone files (URL2FILE.EXE and Readme.txt). I suggest just using the standalone EXE.
Usage is show a bit further down the download page and there is another "Tip" page showing usage in a batch file:
http://www.chami.com/tips/windows/062598W.html
I prefer this for simple single file fetching to FTP.EXE, but you need to specify the FTP Protocol, eg. target URL, eg:
ftp://data.ftse.com/data/gilts/gilts_constituents/BGCO1904.csv
Hmmm. I see that you can also enter (on login) via http://data.ftse.com/HttpPull/login.jsp
ASKER
Hi Bill & SirBounty,
Firstly thanks for helping me.
Sadly I'am not allowed (or able) to download anything onto my computer, company is very strict, which is a pain in neck! I like the idea of entering the login although when we had the account setup I was warned by the data provider that sometimes you will have to log in twice, they have some bug there end by the sounds of it!
I have tried the new code you have writting with no luck, I have written to the data provider to see if it is an error their side. Will let you know what they come back with when they do get back to me.
Thanks,
Firstly thanks for helping me.
Sadly I'am not allowed (or able) to download anything onto my computer, company is very strict, which is a pain in neck! I like the idea of entering the login although when we had the account setup I was warned by the data provider that sometimes you will have to log in twice, they have some bug there end by the sounds of it!
I have tried the new code you have writting with no luck, I have written to the data provider to see if it is an error their side. Will let you know what they come back with when they do get back to me.
Thanks,
Please open a cmd prompt (Start->Run->cmd <Enter>) and test this manually, step-by-step...
The same commands should work for you one line at a time. Check if any come back with an error when it's not automated:
ftp <enter>
lcd G:\Shared\FixedI~1\Soverei gn\Mark\FT P <enter> (success?)
open data.ftse.com <enter>
username <enter>
password <enter> (connected?)
prompt n <enter> (though this is irrelevant when stepping through)
cd data/gilts/gilts_constitue nts <enter> (success?)
get BGCO1904.csv overwrite <enter> (success?)
bye <enter>
The same commands should work for you one line at a time. Check if any come back with an error when it's not automated:
ftp <enter>
lcd G:\Shared\FixedI~1\Soverei
open data.ftse.com <enter>
username <enter>
password <enter> (connected?)
prompt n <enter> (though this is irrelevant when stepping through)
cd data/gilts/gilts_constitue
get BGCO1904.csv overwrite <enter> (success?)
bye <enter>
ASKER
I will try it on my home computer (and make the adjustments to the file locations) after work, as our IT are a bit control freakish, we do not have the option of Run from out Start menus.
Any update?
ASKER
Hi Sirbounty,
I am going to chance the data provider up again today & soon as I hear anything will let you know.
Thanks
I am going to chance the data provider up again today & soon as I hear anything will let you know.
Thanks
Recommend split http:#31272662 and http:#31273324
Automated script was provided, as was Bill's most excellent description of the commands and how they work. I believe the author got what they were after...
Automated script was provided, as was Bill's most excellent description of the commands and how they work. I believe the author got what they were after...
Thak you SirBounty and Vee_Mod
So, the only interpretation needed from the batch file, is technically irrelevant, provided you place those comands in your ftp script file. Those commands simply changed to the proper drive, and subsequently, the proper folder. But that's easily handled in the script file.
I would suggest modifying it to the attached code.
Your batch file becomes a one-liner. Simply use:
@ftp -s:c:\Path_To_FTPScript\tx
Please let us know if you need further assistance.
Here's a couple of sites to explain more on automating FTP, if you're curious.
http://support.microsoft.com/kb/96269
http://www.robvanderwoude.com/ftp.php
Open in new window