AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Source Servers (SRCDS) (https://forums.alliedmods.net/forumdisplay.php?f=130)
-   -   SRCDS windows output redirection (https://forums.alliedmods.net/showthread.php?t=287902)

Peace-Maker 09-17-2016 22:25

SRCDS windows output redirection
 
4 Attachment(s)
SRCDS output redirection on windows

Redirecting the server output to a file or other monitoring program wasn't easily possible, because the SRCDS allocated a new console on windows and didn't use the stdout/stdin.

Over at Facepunch, Megalan posted something about "-HFILE -HPARENT -HCHILD" command line options for srcds.exe to redirect the output. After some searching, I've only found references to a long-dead server management tool for Quake 1 called "QHost", for which those parameters were initially added. Luckily they persisted in the engine code until now.

Sadly those parameters aren't exactly for redirecting output, but rather give the possibility to request the last X lines of output and enter some commands from a different program. I wasn't able to really produce a tool that outputs new lines as they appear in the server commandline reliably.
The attached program does output it correctly, but might get confused when the process window gets resized. QHost apparently expected the server console window to always be of 80 width in size and didn't provide an API call to get the current actual size of the window. You might be able to get the size from the process window itself, but my windows-fu isn't strong enough for that (+ lack of interest).

To use this tool, place the SrcdsConRedirect.exe next to the srcds.exe and just call it in place of that - but redirect the output somewhere if you want ;)
Code:

C:\path\to\srcdsserver\SrcdsConRedirect.exe -game cstrike -port 27015 -console +map de_dust2 > console.output
Might be of some use for administration tools like seDirector, so you could send console commands directly to the server without any hacks, just by using the SRCDSControl class in the source package.

The provided methods in the dedicated conproc API are wrapped like
Code:

int GetScreenBufferSize();
bool SetScreenBufferSize(int iLines);
bool WriteText(string input);
string ReadText(int iBeginLine, int iEndLine);


Snaggle 09-20-2016 20:10

Re: SRCDS windows output redirection
 
I'm getting the error "Invalid String Position" when trying to run this.

If my understanding is correct, this would allow me to output the text from the SRCDS console window to a text file, right? I've tried the following...

Code:

C:\servers\server>SrcdsConRedirect.exe -console -game tf +maxplayers 24 +map achievement_botfarm_v8 -port 27010 > C:\console.txt
The file is made, but it's 0 bytes and the SRCDS window closes almost instantly.

Peace-Maker 09-21-2016 14:30

Re: SRCDS windows output redirection
 
Hm, I can't reproduce that, but I've tried to fix it. Have a go again ;)

Arciduca Zagaria 01-10-2020 19:21

Re: SRCDS windows output redirection
 
hi, thank you for writing this tool.
How can I write to the stdin of srcds using c# language?

Sorry for the question but I'm new in this kind of stuff.

Alienmario 08-12-2023 16:22

Re: SRCDS windows output redirection
 
If anyone finds this in current year,
Alien Swarm: Reactive Drop server includes srcds_console.exe which doesn't spawn another window and can be freely used across all Sourceš games.
Source: https://github.com/Facepunch/garrysm...ent-1507467323

Austin 09-01-2023 02:06

Re: SRCDS windows output redirection
 
Add this parm to your servers start up command line.
It will log all console output into the console.log text file.
-condebug

https://developer.valvesoftware.com/...d_line_options

-condebug // Logs all console output into the console.log text file.


The file will be here
..\<game>\console.log

??

Fraggor 09-28-2023 18:45

Re: SRCDS windows output redirection
 
Here's a snippet of my srcds_launch.bat, please read the comments and feel free to point out any incorrect information
Spoiler


All times are GMT -4. The time now is 18:14.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.