Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Standard Output Stream of CLI

Level 7

Standard Output Stream of CLI

I am trying to add some kind of Interface class to an existing VB Project in order to be able to acces the IMS services.

My current solution uses the command line interface, which works pretty fine. The only problems I have are related to "im createcontent" and "im createissue". In those cases I want to know the ID of the created objects but the streamreader object in my software seems so be empty (please see code snippet) 

VB.NET Code of CmdLineInterface Function: 

    Private Function RunCommandCom(command As String, arguments As String) As String()

        Dim p As Process = New Process()
        Dim pi As ProcessStartInfo = New ProcessStartInfo()
        Dim output As String

        pi.Arguments = " " + "/c" + " " + command + " " + arguments
        pi.FileName = "cmd.exe"
        pi.RedirectStandardOutput = True
        pi.CreateNoWindow = True
        pi.WindowStyle = ProcessWindowStyle.Hidden
        pi.UseShellExecute = False
        p.StartInfo = pi

        Using streamReader As System.IO.StreamReader = p.StandardOutput
            output = streamReader.ReadToEnd()
        End Using

        If output Is "" Then
            Return Nothing
            Return output.Replace(Chr(13), "").Split(Chr(10))
        End If

    End Function


The RunCommandCom() function works fine for querys. Also calling other executables like "ipconfig" works fine. What is the difference when calling "im createcontent"? Is it possible to read back the ID of the created object with this solution? 


Re: Standard Output Stream of CLI

Ok, I found the problem. Some funny developer decided to send the output of "im createcontent" and "im createissue" to the stderr stream instead of sending it to stdout.


Is this a feature or a bug?

Re: Standard Output Stream of CLI

Probably by design - though, it seems confusing design.  Is it status info that is being returned?  I think the CLI directs all the "status" return info, to stderr.  That may be what you're seeing.


Some of this, is why customers were pointed to the API over the years, where possible.

Re: Standard Output Stream of CLI

I don't think this is just a status info as I create some issue/content and the returned text contains the ID of this issue/content. So for my understanding this should be sent to stdout. But it's ok as long as I know that i have to search for this infroamtion in the stderr sometimes Smiley Happy


And yes, after finishing my work I also thought about using the API next time. But for a quick script, the CLI is perfect...