We have PC .bat file that executes a file on the C: drive that FTPs to our AS/400 with the user ID and password hard coded into a script file. Is there a way to stop this hard-coded user ID and password and ask for the user ID and password? We have to change passwords every 90 days now to comply with credit card security.
QUESTION POSED ON: 02 JUN 2005
QUESTION ANSWERED BY: Shahar Mor
It is very easy. Your FTP script reads a text file (i.e., script.txt) which looks like this:
open ftp.mysite.com
user
password
get file
bye
Then you could execute it like this:
ftp -s:SCRIPT.TXT
You can replace it with this batch file (original post from Tom Lavedas)
@ECHO OFF
:: Check if the password was given
IF "%1"=="" GOTO Syntax
:: Create the temporary script file
> script.ftp ECHO MyUserId
>>script.ftp ECHO %1
>>script.ftp ECHO cd files/pictures
>>script.ftp ECHO binary
>>script.ftp ECHO prompt n
>>script.ftp ECHO mget *.*
:: Use the temporary script for unattended FTP
:: Note: depending on your OS version you may have to add a '-n' switch
FTP -v -s:script.ftp ftp.myhost.net
:: For the paranoid: overwrite the temporary file before deleting it
TYPE NUL >script.ftp
DEL script.ftp
GOTO End
:Syntax
ECHO Usage: %0 password
:End
I would also consider setting up anonymous FTP so a password will not be needed at all.
|