Expert Answer Center > Experts On Demand > View Answer
EMAIL THIS
Experts on Demand
  EXPERTS ON DEMAND HOME     POSE A QUESTION     VIEW ANSWERS     BROWSE BY TOPIC        RSS FEEDS  
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.
HomeExperts on DemandIT Expert Webcast SeriesExpert KnowledgebaseSite Index
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts