Sign in to follow this  
Followers 0
computergeekxp

StdOutRead Help

8 posts in this topic

#1 ·  Posted (edited)

I am trying to write a GUI for the halo pc dedicated server but when I tried to retrieve the console text nothing happens...Nothing is put out when either StdOurRead or StdErrorRead. I have searched the forums and can't figure it out...

*After further investigation it looks like the StdoutRead never terminates even when peek is set to true or I try to get the number of characters it is able to read...

#include <inet.au3>
#include <Constants.au3>
#include <GUIConstants.au3>
$dll = DllOpen("psapi.dll")

Global $STARTED=FALSE
Global $ServerH=""

AutoItSetOption("GUIOnEventMode", 1)
GUICreate("Halo(1.07) SERVER MANAGER",500,300)

;set up bottom row
$StatusButton=GUICtrlCreateButton ("Start Server", 0,275,75)
GUICtrlSetOnEvent(-1, "StartStopServer")

$StatusLabel=GUICtrlCreateLabel ( "Waiting...", 160, 280,340)

;set up server status tab
GUICtrlCreateTab (0,0, 500,275)
GUICtrlCreateTabitem ("Status")

GUICtrlCreateGroup ( "Map", 10, 30, 150,225)
GUICtrlCreateLabel("IP:" & StringTrimLeft(_GetIP(),122) & "[PORT!!]",18,195)


GUICtrlCreateTabitem("Console")
$ConsoleLabel=GUICtrlCreateLabel("Loading...",10,30,490,225)

;done setting up GUI
GUISetState()

;FUNCTIONS



Func StartStopServer()
    
    If $STARTED==FALSE Then
        
        GUICtrlSetData($StatusLabel,"Server Starting...")
        $STARTED=StartServer()
        
    Else
        
        GUICtrlSetData($StatusLabel,"Server Stopping...")
        $STARTED=StopServer($STARTED)
        
    EndIf
    
    ServerStatus()
EndFunc

Func ServerStatus()
    
    If $STARTED==FALSE Then
        
        GUICtrlSetData($StatusButton,"Start Server")
        GUICtrlSetData($StatusLabel,"Server Stopped!")
        GUICtrlSetData($ConsoleLabel,"")
        
    Else
        
        GUICtrlSetData($StatusButton,"Stop Server")
        GUICtrlSetData($StatusLabel,"Server Started!")
        
        GUICtrlSetData($ConsoleLabel,"TEST:" & StdoutRead($STARTED))
    EndIf
    
    
EndFunc

Func StartServer()
    AutoItSetOption("RunErrorsFatal",0)
    $ServerH=Run("haloded.exe","",@SW_SHOW,($STDERR_CHILD + $STDOUT_CHILD))

    If @error Then
        
        MsgBox(48,"ERROR!","Unable to run the dedicated server 'haloded.exe'! Please move this file to the directory your dedicated server app is located...")
        Exit
    Else
        
        Return $ServerH
        
    EndIf
    
    AutoItSetOption("RunErrorsFatal",1)
EndFunc

Func StopServer($ServerH)

    ProcessClose($ServerH)
    sleep(500)
    
    If ProcessExists($ServerH) Then
        
        sleep(5000)
        ProcessClose($ServerH)
        If ProcessExists($ServerH) Then MsgBox(48,"ERROR!","Unable to shutdown the Dedicated Server!")
        Return($ServerH)
        
    Else
        Return FALSE
        
    EndIf
EndFunc

Func OnAutoItExit()
   StopServer($STARTED)
EndFunc

While 1
    ServerStatus()
Sleep(1000)
WEnd

The server can be obtained from here

This is the site here...

Edited by computergeekxp

Share this post


Link to post
Share on other sites



I am trying to write a GUI for the halo pc dedicated server but when I tried to retrieve the console text nothing happens...Nothing is put out when either StdOurRead or StdErrorRead. I have searched the forums and can't figure it out...

*After further investigation it looks like the StdoutRead never terminates even when peek is set to true or I try to get the number of characters it is able to read...

I'm running Windows XP SP2. I only get the blocking condition if I'm not doing a peek, which would be expected if there's 0 bytes to be read and none forthcoming.

I altered the read section to look like:

; Call StdoutRead to get a count of characters waiting
If StdoutRead($STARTED, 0, 1) Then
    GUICtrlSetData($ConsoleLabel,"TEST:" & StdoutRead($ServerH, 10, 1))
EndIf

...and loaded the AutoIt3 .98 beta release and stepped through the source code in a debugger. AutoIt did get a valid STDOUT pipe connection from the Halo server, but nothing was ever written to it by Halo.

The Halo server does seem to use a traditional console window for output, so I have to wonder if the behavior is intentional, i.e. that Halo doesn't produce any output if it doesn't detect a standard console window connected to STDOUT. Windows XP's telnet.exe is another example of an app that won't run right if its STDOUT is redirected...


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks for your help! :lmao: I did some searching for a way to output a telnet process and I found this written C++

char psBuffer[128];
     FILE *telnet;
    /* Run telnet so that it writes its output to a pipe. Open this
    * pipe with read text attribute so that we can read it 
    * like a text file. 
    */
     if( (telnet = _popen( "cdrecord --help", "rt" )) == NULL )
     exit( 1 );
     /* Read pipe until end of file. End of file indicates that 
    * telnet closed its standard out (probably meaning it 
    * terminated).
    */
     while( !feof( telnet ) )
     {
     if( fgets( psBuffer, 128, telnet ) != NULL )
     printf( psBuffer );
     }
     /* Close pipe and print return value of telnet */
     printf( "\nProcess returned %d\n", _pclose( telnet ) );

Here is the page

The above code opens a pipe but only gets the contents when it's terminated. I tried doing a pipe (command | alternate command) in DOS but I am not sure how the program it reverts this stream to accesses it. I think that if I were to find out a way to do this in autoit I could actually access the console text but not sure how I would send commands to it...

Edited by computergeekxp

Share this post


Link to post
Share on other sites

I will assume that all this dead time is because of the very indepth and creative responces your coming up with right :lmao:

Share this post


Link to post
Share on other sites

This is what StdoutRead does, amigo, it connects to the child process's STDOUT pipe. StdinWrite would let you write the the child process's STDIN pipe, which would be like typing to the console.

I know that you were trying to be helpful with the above code sample, but's it's a second or third generation cut-and-paste code fragment, if you'll notice despite the variable names of 'telnet' for the variables that the actual command line is for cdrecord...

I don't have Halo for the PC and the dedicated server won't run without it, so I don't know how much more help I can be, other than repeating that there are some apps that don't work as expected if their console pipes are redirected. Beyond that you might try:

$ServerH=Run(@ComSpec & ' /c "C:\Program Files\Microsoft Games\Halo Server\haloded.exe"',"C:\Program Files\Microsoft Games\Halo Server",@SW_SHOW,($STDOUT_CHILD))

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You can actually use the link posted above which will allow you to dowload the server. The server itself is actually just the bare bones an can be run w/o any more files. To actually host maps you will need to download the map-pack for the server. Both are free and can be run without the game installed/a cd key...

Edited by computergeekxp

Share this post


Link to post
Share on other sites

No luck so far but right now I am downloading the latest beta release. Apparently it was just released today :lmao:

Share this post


Link to post
Share on other sites

What information are you trying to get from Haloded ?


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

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