SFTP - passing a password from within a script

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
cdp
Premium Member
Premium Member
Posts: 113
Joined: Tue Dec 15, 2009 9:28 pm
Location: New Zealand

SFTP - passing a password from within a script

Post by cdp »

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,
ajay.vaidyanathan
Participant
Posts: 53
Joined: Fri Apr 18, 2008 8:13 am
Location: United States

SFTP - passing a password from within a script

Post by ajay.vaidyanathan »

Hi,
You cannot set the password parameter as a public key. You need to MASK your password value in Unix and then pass it as a parameter to the file.
Regards
Ajay
Post Reply