SFTP - passing a password from within a script
Posted: Tue Mar 15, 2011 8:19 pm
I am creating a batch script to call the SFTP server. Calling the batch scripts in the datastage sequencer execute command stage.
below is my command in the batch scripts.
setlocal enabledelayedexpansion
SET ROOTVALUE=%1
SET FILE_LOC=%2
SET FTP_SRVR=%3
SET FTP_FLDER=%4
SET FTP_USER=%5
SET FTP_PWD=%6
SET FILE_NAME=%7
CD %ROOTVALUE%
ECHO %FTP_PWD% > %ROOTVALUE%\filename.txt
ECHO LCD %ROOTVALUE%%FILE_LOC% >> %ROOTVALUE%\filename.txt
ECHO CD %FTP_FLDER% >> %ROOTVALUE%\filename.txt
ECHO PUT %FILE_NAME%.md5 >> %ROOTVALUE%\filename.txt
ECHO QUIT >> %ROOTVALUE%\filename.txt
SFTP -s ROOTVALUE%\filename.txt %FTP_USER%@%FTP_SRVR%
it is asking for a password, i have specified the password in the filename.txt file but it is not fetching the values from the file. rather it is prompting for a password.
Note: the passowrd is set as public key
Can any body help me in passing the password value to the prompt using the filename.txt.
Thanks,
below is my command in the batch scripts.
setlocal enabledelayedexpansion
SET ROOTVALUE=%1
SET FILE_LOC=%2
SET FTP_SRVR=%3
SET FTP_FLDER=%4
SET FTP_USER=%5
SET FTP_PWD=%6
SET FILE_NAME=%7
CD %ROOTVALUE%
ECHO %FTP_PWD% > %ROOTVALUE%\filename.txt
ECHO LCD %ROOTVALUE%%FILE_LOC% >> %ROOTVALUE%\filename.txt
ECHO CD %FTP_FLDER% >> %ROOTVALUE%\filename.txt
ECHO PUT %FILE_NAME%.md5 >> %ROOTVALUE%\filename.txt
ECHO QUIT >> %ROOTVALUE%\filename.txt
SFTP -s ROOTVALUE%\filename.txt %FTP_USER%@%FTP_SRVR%
it is asking for a password, i have specified the password in the filename.txt file but it is not fetching the values from the file. rather it is prompting for a password.
Note: the passowrd is set as public key
Can any body help me in passing the password value to the prompt using the filename.txt.
Thanks,