Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

 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?

0 votes



One answer

Permanent link
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.

0 votes

Comments

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

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 log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,019
× 1,202
× 457
× 158
× 87

Question asked: Jan 27 '14, 10:03 a.m.

Question was seen: 5,876 times

Last updated: Feb 09 '15, 9:54 p.m.

Confirmation Cancel Confirm