Is there a way in SCM CLI that password can be given from password file?
Accepted answer
The following works on Windows (a similar technique can probably be used in UNIX/Linux with "cat"):
C:\Temp>type pw.txt | lscm login -r https://jazz.somedomain.com:9443/ccm/ -n jazz -u someuser -c
Password (someuser @ https://jazz.somedomain.com:9443/ccm/):
Logged in to https://jazz.somedomain.com:9443/ccm/
C:\Temp>lscm logout -r jazz
Successfully logged out of https://jazz.somedomain.com:9443/ccm/
Note: the password prompt still appears at the terminal but nothing need be typed; it takes the password piped to it from standard in.
In this example pw.txt contains the password in plain text but it wouldn't be much of a stretch to have the password stored using some sort of encryption and instead of "type" (or "cat" on UNIX/Linux) use a program that will decrypt it to standard out so it can be piped to the lscm command.
C:\Temp>type pw.txt | lscm login -r https://jazz.somedomain.com:9443/ccm/ -n jazz -u someuser -c
Password (someuser @ https://jazz.somedomain.com:9443/ccm/):
Logged in to https://jazz.somedomain.com:9443/ccm/
C:\Temp>lscm logout -r jazz
Successfully logged out of https://jazz.somedomain.com:9443/ccm/
Note: the password prompt still appears at the terminal but nothing need be typed; it takes the password piped to it from standard in.
In this example pw.txt contains the password in plain text but it wouldn't be much of a stretch to have the password stored using some sort of encryption and instead of "type" (or "cat" on UNIX/Linux) use a program that will decrypt it to standard out so it can be piped to the lscm command.
Comments
Hi Alan,
Thank you for your response. Somehow using 'type' and pipe i wasnt able to provide it as input to my command.
However your answer gave me an idea on the direction to go for.
Here is what I did.
set /p pwd=<pw.txt
cd <path>\jazz\scmtools\eclipse
call lscm login -r https://<server>/ccm -n jazz -u usrname -P %pwd%
That's because the -P / --password switch is not interactive so doesn't prompt. Using -c / --cache switch prompts for a password which it will take from the pipe.
Caching the password has other benefits too such as storing the password in an obfuscated form to make it more difficult to read and saving the password over a login session so you don't need to provide a password with each new command.
1 vote