It's all about the answers!

Ask a question

How to build a check when scm list credentials doesn't return any message and ErrorLevel=0 when not logged in?


Danny Beerens (801828) | asked Jan 27 '14, 10:03 a.m.
edited Jan 27 '14, 10:04 a.m.
 Hi all,

I am using RTC CLI 4.0.2 on Win7 64-bit.
You can store (l)scm login credentials with argument '-c' in the command: scm login -r %SrvURI% -u %UserID% -P %UserPwd% -n %SrvURInickname% -c.
When I want a script to check the (l)scm login credentials, you can use command: scm list credentials.

If login credentials are available the return says:
%SrvURI%, %UserID%, %SrvURInickname%, <No certificate>, <No smartcard>, <Password stored>
Enough return values to check and %ERRORLEVEL% is 0, which is as expected.

However, when there are -no- credentials stored, i.e. there's no rtc login, the command 'scm list credentials' doesn't return -any- value and %ERRORLEVEL% is 0.

When I do a: FOR /F %%i IN ('scm list credentials') DO echo Value 1=%%i, I get nothing returned, not even "Value i="

How can I create a check in my batch file to see if a login is available?
Any pointers?

One answer



permanent link
Shashikant Padur (4.2k27) | answered Jan 28 '14, 5:52 a.m.
JAZZ DEVELOPER
You can set a variable before the for loop (something like credExists=0) and then inside the for loop set credExists=1. Check for the value of the variable 'credExists' to determine if there was any credential information.

Comments
Danny Beerens commented Feb 09 '15, 7:20 a.m.

 This workaround works fine, but the command still doesn't return a proper error code.


Shashikant Padur commented Feb 09 '15, 9:54 p.m.
JAZZ DEVELOPER

Probably there could have been a return value indicating that there is no login credentials but currently it is working as designed.

By the way, you could also try using the --json option to output it in json format. In that case you could check if the array is empty.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.