It's all about the answers!

Ask a question

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


Tayaka Mizushima (622016) | asked Jun 10 '12, 9:49 p.m.
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.

2 answers



permanent link
Sridevi Sangaiah (59179) | answered Jun 11 '12, 3:42 a.m.
JAZZ DEVELOPER
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



permanent link
Karl Weinert (2.0k42536) | answered Jun 11 '12, 4:33 p.m.
JAZZ DEVELOPER
edited Jun 11 '12, 5:13 p.m.
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

Your answer


Register or to post your answer.