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

RTC-SCM-CLI: what is the right way to launch lscm.bat from a C#.NET wrapper tool (running in windows)

Background:
------------------
I'm building a wrapper tool (C# .net) around the RTC SCM CLI
This wrapper tool is a GUI application with some set of menu commands like "Login to RTC", "Load Component" etc., This wrapper tool internally calls lscm.bat (from RTC-scmTools-Win-4.0.3 installation)

On click of every menu command (RTC specific), the wrapper tool launches "lscm.bat" in a new process with appropriate CLI arguments for that command. Find below the C# code:
--------------------------------------------------------------------------------------------------------------------------------------------
            ProcessStartInfo processStartInfo = new ProcessStartInfo(BatchFilePath, CmdLine);
            processStartInfo.CreateNoWindow = true;
            processStartInfo.UseShellExecute = false;
            processStartInfo.RedirectStandardOutput = true;
            processStartInfo.RedirectStandardError = true;
            System.Diagnostics.Process process = System.Diagnostics.Process.Start(processStartInfo);
            StreamReader StdOutReader = process.StandardOutput;
            StreamReader StdErrReader = process.StandardError;           
            process.WaitForExit();
            string StdOutMessage = StdOutReader.ReadToEnd();
            string StdErrMessage = StdErrReader.ReadToEnd();
            int ExitCode = process.ExitCode;
            StdOutReader.Close();
            StdErrReader.Close();
--------------------------------------------------------------------------------------------------------------------------------------------

As shown in the code above, the wrapper tool captures the STDOUT and STDERR streams of lscm.bat for its own processing and display.

Problem:
-------------
1. The wrapper tool with the above code was working fine for the below commands
- login
- list components
- create changeset
- checkin
- logout

2. Then, I executed the command
load -r <server> -d <RootDir> -f <workspace> <ComponentName>
=> I waited for about 10 mins, but the command did not return at all.
It looked like the command was hanging. So I opened Task manager and killed "scm.exe". Now the command returned immediately.

3. I closed the wrapper tool. Restarted it. And now, every RTC SCM CLI command that I'm executing (eg, login command) doesn't return at all. If I explicitly kill the scm.exe then the command returns immediately.

Summary
--------------
1. For every command triggered by the user in the wrapper tool, it is launching the lscm.bat in a separate process. Is this the right way to launch the lscm.bat ? Or is there a better approach available ?
2. What could be the reason behind the scm cli commands not returning ? (Please note that if I launch scm.exe instead of lscm.bat, then this issue doesn't occur)
3. Can you share some documentation on how this lscm.bat/scm.exe/fec.exe work together internally ? (I'm reading that lscm.bat will start scm.exe as a daemon but I couldn't find anything in windows services list. I could only find scm.exe running as a process in Task manager.)

Thanks for your help in advance.

1 vote



One answer

Permanent link
For 1) and 2) refer to https://jazz.net/forum/questions/77400/calling-lscmbat-from-a-build-script-causes-a-hang
3) The daemon is being launched as a background process and not as a windows service.

2 votes

Comments
  1. Does it mean the below steps for me ?
  2. Execute scm.exe with start daemon command
         - Execute lscm.bat with login command
         - Execute lscm.bat with load command
         - ......
         - Execute lscm.bat with logout command
  3. Execute scm.exe with stop daemon command

  4. What happens if I mix up the sandbox specific and non-sandbox specific lscm.bat calls in between my login & logout commands above ? As you have mentioned in the other post, it will launch another scm.exe right ? In that case, will lscm.bat hang again ?

 1. That sounds right but you may want to validate if there isn't a running daemon before you start a daemon.

2. If you run the remote (non-sandbox) calls from the same sandbox location then it will not launch a new daemon. But if run from different path, then yes, it will launch a new daemon.

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
× 10,938
× 1,202
× 158
× 113
× 87

Question asked: Oct 29 '13, 1:15 a.m.

Question was seen: 8,163 times

Last updated: Dec 13 '13, 11:20 a.m.

Confirmation Cancel Confirm