Friday, January 27, 2006

scripted FTP in DOS

When you want to send files from a DOS prompt in Windows to some other machine, this script may come in handy. Modify as fit; one might for instance want to send more than one file.
Because I'd rather not hardcode a password into the script, the script tries to get that from an environment variable.

@echo off

rem script to quickly get a file from /home/userid/ff on hostname.domain.
rem userid is hardcoded, set property FTPPASS in environment before use.

if "%FTPPASS%"=="" goto nopass
if "%1"=="" goto nofilen

> quickget.ftp echo USER userid
>>quickget.ftp echo %FTPPASS%
>>quickget.ftp echo cd ff
>>quickget.ftp echo bin
>>quickget.ftp echo get %1
>>quickget.ftp echo bye

ftp -n -s:quickget.ftp hostname.domain

del quickget.ftp
goto einde

:nopass
echo No password specified in environment (set FTPPASS=********)
goto einde

:nofilen
echo No file name specified
goto einde

:einde

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.