mandonov avatar image
mandonov asked mandonov posted

standard output from itestcli executed as cgi .bat scripts

I am trying to integrate and iTest test case as a script executed from Gale Technologies' LabManager tool. The integration requires the iTest test case to be executed by using itestcli as a cgi script for Apache web server, using the command below. 

"C:/Program Files/Fanfare/iTest 3.2/itestcli.bat" -w "C:/Fanfare/Workspace" -l "itest_log.txt" -r itest_report.fftr -summary  "project://Spirent_project/Spirent_project/test_cases/stal.fftc" 


As expected, I get std output on the command line, if I execute the above from the command line or as a .bat file. However if I run it as a cgi script as is required by LabManager, I don’t get any standard output back into LabManager's console where I normally see any runtime output. Runtime info is logged in the log file specified by the -l switch -- which is evidence that the test case does get executed and itestcli has _at least_ some level of control over standard out. However, it appears that standard output is redirected somewhere when itestcli executes as a batch script.


Has anyone run into this issue?


I will appreciate any insight into how itestcli handles standard and error output in principle and in this specific case as a cgi script.





10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

KumarS avatar image
KumarS answered KumarS posted



itestcli does not do anything magical about stdout. It uses Java's standard API "System.out.println" to write output to standard out. Java VM now will take that output and based on its implementation try to write to o/s specific way of outputting this data. When run from a Windows command shell, the output appears in the shell.


Else where in the forum, PaulD has explained the difference between Windows Console and Windows STDOUT and this is a very common problem on Windows where stdout produced by a batch file cannot get retrieved. This is because when your CGI program runs this batch file, it ends up creating "Windows Command" process which then runs the batch file. Now your CGI script is trying to get the STDOUT from this Windows command process rather than the itestcli process.



So in order to fix the problem, you can try two different things:

1. Look inside itestcli.bat and run what itestcli.bat is running directly i.e. run the "java" program from your CGI script. This will make for a longer and uglier command to execute in your CGI script and may change from one release of iTest to another.

2. You can try: cmd /c "C:/Program Files..... - this is not guaranteed to work - but you may be able to get the stdout from a command shell running with "cmd /c" option.


You should also try an experiment of simply creating a batch file which does "echo foo" and see if you get the stdout from that batch file.


If you report results of these, we may be able to help you further. 


10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mandonov avatar image mandonov commented ·

Hi Kumar, 


indeed it turned out the issue was that the output from itestcli has to be explicitly outputted by the cgi script in order to have the web server send the stdout into the http response. Since I don't know DOS batch scripting, I resorted to running a Tcl cgi script that does


puts [exec "C:/Program Files/Fanfare/iTest 3.2/jre/bin/java" -classpath ....


This works as long as the itestcli test case returns a "Pass". When it returns a "Fail" or "Indeterminate", the parent Tcl process reports "Child exited abnormally.." and the output gets redirected to stderr and therefore straight into Apache's logs/error.log. Just as a comment, I don't think the itest testcase process should return an error status upon exit but rather some sort of status message or a testable value.


However I can work with the way this works at the moment so we can consider this question closed.


Thanks for the suggestions.




0 Likes 0 ·
KumarS avatar image KumarS mandonov commented ·

itestcli process returns 0 if a testcase passes and 1 if it fails. I do not know off hand - but you can tweak your tcl code to deal with the return code of 1.


Also - you may be able to execute  "C:/Program Files/Fanfare/iTest 3.2/jre/bin/java" directly as your CGI program and that way you do not have deal with some intermediate process interpreting standard out or error.

0 Likes 0 ·
mandonov avatar image mandonov KumarS commented ·
Yes - running  "C:/Program Files/Fanfare/iTest 3.2/jre/bin/java" directly as a cgi script is possible, but I would have to deal with echoing its output from the batch file - which I was not successful in doing. But it certainly should be possible.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.