Sign in to follow this  
Followers 0
tlman12

Reading a programs output stream

5 posts in this topic

Alright so i have this console based application that runs and displays info within the command prompt. I need to be able to read and send that info via tcp to another server logging application.

the program is DSM from computer associats and the console app i'm running is dmsweep.exe

i have been succesfull with other applications using the stdreadout but this program dosn't seem to be, i guess, outputting the data in a standard way?

i even tried the cmd /c dmsweep.exe >> output.log and unlike most programs that output each line as it's displayed this one dosn't seem to do it

is there a way to get around this? or something else i can try?

i have also tried stdreadout($foo,true,true) and stdreadout($foo,false,true)

thank you for your help.

Share this post


Link to post
Share on other sites



obvously you won't be able to run it withough dsm but here it is. maybe i am making a stupid syntax error?

i did try to change the run to a ping and it's returning my results correctly so i don't think thats it

]#include <Constants.au3>

dim $prevMsg = ""
dim $server, $nPORT
$server = IniRead("Server.ini","main","ServerIP","")
if $server = "" then Exit
local $nPORT = 33891, $nPORTclient = 33892

If $cmdLine[0] = "" Then
    MsgBox(16, "Error", "This program can not be run alone.")
Else
    TCPStartup()
    $foo = Run('cmd /c c:\temp\dmsweep.exe deploy /mgr CCSADUM /ip ' & $cmdLine[1] & " /pn 9 /pparams " & $cmdLine[2] & ",, /tu " & $cmdLine[3] & " /tp " & $cmdLine[4]','',@SW_SHOW,$STDERR_CHILD + $STDOUT_CHILD)
    while 1
        $msg = StdoutRead($foo,True)
        MsgBox(0,"",$msg)
        if not $msg = "" Then
            if not $msg = $prevMsg Then
                $ConnectedSocket = -1
                $ConnectedSocket = TCPConnect($server, $nPORT)
                $ConnectedSocket2 = -1
                $ConnectedSocket2 = TCPConnect($cmdLine[1], $nPORTclient)
                If @error Then
                    MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error & @crlf & @CRLF & "Please make sure the server is running and then click ok")
                    $ConnectedSocket = TCPConnect($server, $nPORT)
                    if @error then
                        MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error & @crlf & @CRLF & "Still unable to connect to server, Please try again later")
                    EndIf
                EndIf
                if $ConnectedSocket > 0 Then
                    TCPSend($ConnectedSocket, $cmdLine[1] & "," & $msg)
                    TCPSend($ConnectedSocket2,$msg)
                    if StringInStr($msg,"SUCCESS") Then
                        ExitLoop
                    EndIf
                EndIf
            EndIf
        EndIf
        sleep (10)
    WEnd
    FileDelete("\\" & IniRead("Server.ini", "main", "SessionServer", "27.27.41.1") & "\Sessions\" & $cmdLine[1])
EndIf

#include <Constants.au3>

dim $prevMsg = ""
dim $server, $nPORT
$server = IniRead("Server.ini","main","ServerIP","")
if $server = "" then Exit
local $nPORT = 33891, $nPORTclient = 33892

If $cmdLine[0] = "" Then
    MsgBox(16, "Error", "This program can not be run alone.")
Else
    TCPStartup()
;~  $foo = Run('cmd /k c:\temp\dmsweep.exe deploy /mgr CCSADUM /ip ' & $cmdLine[1] & " /pn 9 /pparams " & $cmdLine[2] & ",, /tu " & $cmdLine[3] & " /tp " & $cmdLine[4]','',@SW_SHOW);,$STDERR_CHILD + $STDOUT_CHILD)
    $foo = run('cmd /c ping -t ccsdeploy','',@SW_SHOW,$STDERR_CHILD + $STDOUT_CHILD)
    while 1
        $msg = StdoutRead($foo,True)
        MsgBox(0,"",$msg)
        if not $msg = "" Then
            if not $msg = $prevMsg Then
                $ConnectedSocket = -1
                $ConnectedSocket = TCPConnect($server, $nPORT)
                $ConnectedSocket2 = -1
                $ConnectedSocket2 = TCPConnect($cmdLine[1], $nPORTclient)
                If @error Then
                    MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error & @crlf & @CRLF & "Please make sure the server is running and then click ok")
                    $ConnectedSocket = TCPConnect($server, $nPORT)
                    if @error then
                        MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error & @crlf & @CRLF & "Still unable to connect to server, Please try again later")
                    EndIf
                EndIf
                if $ConnectedSocket > 0 Then
                    TCPSend($ConnectedSocket, $cmdLine[1] & "," & $msg)
                    TCPSend($ConnectedSocket2,$msg)
                    if StringInStr($msg,"SUCCESS") Then
                        ExitLoop
                    EndIf
                EndIf
            EndIf
        EndIf
        sleep (10)
    WEnd
    FileDelete("\\" & IniRead("Server.ini", "main", "SessionServer", "27.27.41.1") & "\Sessions\" & $cmdLine[1])
EndIf

Share this post


Link to post
Share on other sites

You have a syntax error in the Run() posted script but I guess you haven;t tested with this one. It has an extra quote after $cmdLine[4].

Have you tried StderrRead() to see if the output is written to stderr in stead of stdout?


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You have a syntax error in the Run() posted script but I guess you haven;t tested with this one. It has an extra quote after $cmdLine[4].

Have you tried StderrRead() to see if the output is written to stderr in stead of stdout?

oh lol yeah i hand't re run it since i removed the ' >> dmsweep.log' lol but the scipt wouldn't have run at all like that

tried the stderrout

$msg = StdoutRead($foo,True) & @crlf & StderrRead($foo,true)

MsgBox(0,"",$msg)

after 3 mins i got nothing from the stdout (which i should have because i know witin 3 mins atleast the first step of the dmsweep process is complete and displayed

and on the stderr i only got the fact that i was initiating cmd prompt with a UNC path and that that was unsupported..

after it is finished with the >> i do get the output which looks like this in the dmsweep.log

but after finishing i get nothing for the stdout in autoit

C:\temp>C:\temp>

C:\temp>Contacting the deployment manager on CCSADUM.

New job id is 31492258.

Retrieving the package list.

Scanning for package CA DSM Agent + AM, RC, SD plugin(s) 12.0.1.1378 Windows_x86 NLS(ENU,DEU,FRA,JPN).

IP SCAN: Package deployed. Credentials required. (1 of 1)

Scan complete.

Deploying package CA DSM Agent + AM, RC, SD plugin(s) 12.0.1.1378 Windows_x86 NLS(ENU,DEU,FRA,JPN).

IP PROGRESS: Package posted.

IP PROGRESS: Deploying primer.

IP PROGRESS: Primer installed.

IP PROGRESS: Package deployed.

Deployment complete.

DEPLOYMENT SUMMARY

===============================================================================

IP SUCCESS: Package deployed.

===============================================================================

C:\temp>

Edited by tlman12

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0