Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm trying to write a DOS batch file that will determine which files are in a directory
on a remote unix box and then write a ftp script go 'get' each of the files.So far I have writen a script that carries out 'ls' on the remote unix box and output the result to a file. The script then uses 'find' to filter out the unwanted filenames. The next part of the script writes a ftp script and outputs the ftp comand 'get' for each of the filenames using a 'for' loop (ie. for /F %%f in (filename) do echo get %%f >> ftpscript). The batch file then executes the ftp script, however when trying to carry out get the error "Cannot open local file X".
The whole script is as below,
@echo off
echo open host > c:\ftp_ls.scr
echo user>> c:\ftp_ls.scr
echo password>> c:\ftp_ls.scr
echo ascii >> c:\ftp_ls.scr
echo ls >> c:\ftp_ls.scr
echo close >> c:\ftp_ls.scr
echo quit >> c:\ftp_ls.scr
ftp -s:c:\ftp_ls.scr > c:\files.lis
echo open host > c:\getfiles.scr
echo user>> c:\sas\dyp\getfiles.scr
echo password>> c:\getfiles.scr
echo ascii>> c:\getfiles.scr
for /F "skip=2" %%f in (c:\sasfiles.lis) do echo get %%f>> c:\getfiles.scr
echo close>> c:\getfiles.scr
echo quit>> c:\getfiles.scr
cd temp
ftp -s:c:\getfiles.scr
cd ..

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |