Raised This Month: $12 Target: $400
 3% 

SRCDS windows output redirection


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 09-17-2016 , 22:25   SRCDS windows output redirection
Reply With Quote #1

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);
Attached Files
File Type: zip SrcdsConRedirect.zip (16.0 KB, 453 views)
File Type: zip SrcdsConRedirect_src.zip (6.9 KB, 396 views)
__________________

Last edited by Peace-Maker; 09-21-2016 at 14:28. Reason: Update for fast scrolling text
Peace-Maker is offline
Snaggle
AlliedModders Donor
Join Date: Jul 2010
Location: England
Old 09-20-2016 , 20:10   Re: SRCDS windows output redirection
Reply With Quote #2

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.

Last edited by Snaggle; 09-20-2016 at 20:15.
Snaggle is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 09-21-2016 , 14:30   Re: SRCDS windows output redirection
Reply With Quote #3

Hm, I can't reproduce that, but I've tried to fix it. Have a go again ;)
__________________
Peace-Maker is offline
Arciduca Zagaria
New Member
Join Date: Jan 2020
Old 01-10-2020 , 19:21   Re: SRCDS windows output redirection
Reply With Quote #4

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.
Arciduca Zagaria is offline
Alienmario
Senior Member
Join Date: Aug 2013
Old 08-12-2023 , 16:22   Re: SRCDS windows output redirection
Reply With Quote #5

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
Alienmario is offline
Austin
Senior Member
Join Date: Oct 2005
Old 09-01-2023 , 02:06   Re: SRCDS windows output redirection
Reply With Quote #6

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

??
Austin is offline
Fraggor
Junior Member
Join Date: Jun 2020
Old 09-28-2023 , 18:45   Re: SRCDS windows output redirection
Reply With Quote #7

Here's a snippet of my srcds_launch.bat, please read the comments and feel free to point out any incorrect information
Spoiler
Fraggor is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:05.


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