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

the script hangs very often while reading lscm command's stderr

I'm developing a script for my customer to automate following operation:

1. Get all file list in the scm load directory
2. For each file, get property by using scm command (lscm property get)
     If succeed, execute some operation using this property
     If failure, show scm command's error message to console & skip next file

My script works, but it hangs up very often while reading stderr of scm command.

To detect problem, I made simple script:

1. execute "lscm property get" to a file few times.
   - lscm command always fail because the file does not have the property
   - read stderr of the command and write those messages to console
2. stop scm daemon

This script also hang up every 1 time to 2 execution.

What's wrong with my script?

Here is the script(VBScipt).
It works
- Windows XP SP3
- RTC3.0.13
-------------------------------------------------------------------------------------------
Option Explicit

Dim objShell
Set objShell = CreateObject("WScript.Shell")
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Copy Stream
Sub CopyStream(objSrcStream, objDestStream)
 Do While (Not objSrcStream.AtEndOfStream)
  objDestStream.WriteLine(objSrcStream.ReadLine)
 Loop
End Sub

Sub Main()

 ' Change current directory to sandbox
 objShell.CurrentDirectory="C:\work\workspace"
 
 ' Get property
 Dim strCmd
 strCmd = "cmd /c lscm.bat property get ""Prop"" ""TestProject/bin/test/Sample.class"" -r https://<rtc-server>:9443/ccm -u user -P password"
  
 Dim i
 Do While i < 10
 
  ' Execute lscm command
  Dim objExec
  Set objExec = objShell.Exec(strCmd)
'  Set objExec = objShell.Exec(strCmd & " >c:\temp\stdout.txt") ' Trial-1: Redirect StdOut to file
 
  Do While objExec.Status = 0
   WScript.Sleep 100
  Loop
 
 ' Read error message
  If (objExec.ExitCode <> 0 ) Then
'   objExec.StdIn.Close ' Trial-2: Close StdIn
'   Call CopyStream(objExec.StdOut, WScript.StdOut)  ' Trial-3: Read StdOut
   Call CopyStream(objExec.StdErr, WScript.StdErr)   ' <--- Script hangs up here
  End If
 
  i = i + 1
 Loop

'Stop daemon
 strCmd = "scm.exe daemon stop C:\work\workspace"
 Set objExec = objShell.Exec(strCmd)
 
 Do While objExec.Status = 0
  WScript.Sleep 100
 Loop
 
 WScript.StdOut.WriteLine("Complete.")

End Sub

Call Main()
-------------------------------------------

In this script I tried some code such as:
- redirect scm command stdout to file
- close stdin before reading stderr
- read stdout before reading stderr
but all code doesn't solve the problem.
The script still hangs up.

0 votes



2 answers

Permanent link
Hi,

This problem sounds to be similar to Test Failure (N20090807-1017): com.ibm.team.filesystem.cli.tests.BasicTests.testRuns (89545). As specified in one of the options in Comment # 3 of the workitem, can you please try starting the daemon before running lscm.

Thanks,
Sridevi


0 votes


Permanent link
There seems to be something going on with the stop and restart of the daemon.

'Stop daemon
 strCmd = "scm.exe daemon stop C:\work\workspace"
 Set objExec = objShell.Exec(strCmd)

Removing that part of the script allows it to run each time.

Edit:
I also found this post which appears to be related
https://jazz.net/forum/questions/77400/calling-lscmbat-from-a-build-script-causes-a-hang

0 votes

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
× 1,202

Question asked: Jun 10 '12, 9:49 p.m.

Question was seen: 8,251 times

Last updated: Jun 11 '12, 5:13 p.m.

Confirmation Cancel Confirm