stdout/stderr for dedicated server not outputting

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

Post Reply
Carolusclen
Engineer
Engineer
Posts: 6
Joined: 31 Dec 2016 10:59

stdout/stderr for dedicated server not outputting

Post by Carolusclen »

Hey everyone

I have looked around for a while online and have come across a few things where this was reported broken and then fixed and then broken etc

Can someone confirm if I can output the console to file? has the method changed, is there a command im missing or has the feature been removed?

I have tried with powershell and C# and I am unable to get the console to output

thanks :)

User avatar
jfs
Tycoon
Tycoon
Posts: 1241
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: stdout/stderr for dedicated server not outputting

Post by jfs »

It does work, at least on non-Windows systems... however I do know we had to do some hackery to get the automated regression tests to work a while back when the current CI on Azure Pipelines was set up. I'm not sure console redirection works for dedicated servers on Windows, possibly only for the "null output" video driver.
There is an alternative command line option that instead sends all console output to a network socket, somehow.

Carolusclen
Engineer
Engineer
Posts: 6
Joined: 31 Dec 2016 10:59

Re: stdout/stderr for dedicated server not outputting

Post by Carolusclen »

ahh ok, that explains it then. I guess on a windows platform I will need to find a way to read it from the network redirect.
I saw a command line for that so thats something to look at.

Thank you :)

Eddi
Tycoon
Tycoon
Posts: 7479
Joined: 17 Jan 2007 00:14

Re: stdout/stderr for dedicated server not outputting

Post by Eddi »

there used to be a "convert" tool that turns a windows gui program into a windows console program.
You might not exactly be interested in Ferion, but if you are, have fun :)

Carolusclen
Engineer
Engineer
Posts: 6
Joined: 31 Dec 2016 10:59

Re: stdout/stderr for dedicated server not outputting

Post by Carolusclen »

yeah I found that but it was messy.

I got it working in the end with a 3rd party tool called netcat.
https://eternallybored.org/misc/netcat/

for anyone who finds this post and wants to do a similar thing, here is what I did.
Download netcat from the above link. I downloaded the 32bit version and extract the nc.exe file to wherever you need it. Mine was in "E:\openttd\Manager"

browse to the folder in powershell ISE.

run this code.

Code: Select all

$process = New-Object System.Diagnostics.Process
$process.StartInfo.UseShellExecute = $false
$process.StartInfo.RedirectStandardOutput = $true
$process.StartInfo.RedirectStandardError = $true
$process.StartInfo.CreateNoWindow = $false
$process.StartInfo.FileName = "E:\openttd\Manager\nc.exe"
$process.StartInfo.Arguments = "-l -p 3982"
$process.Start() | Out-Null

do
{
    $outvar = $process.StandardOutput.ReadLine()
    $outvar
}
while (!$Process.HasExited)

$process.WaitForExit()
what this does is it will open the "nc" application and listen for any incoming information on port 3982.


once that is done, create a shortcut to openttd.exe, right click it and go to properties.
Under target, put these command line options at the end of the line
-D -d 2 -l 10.1.1.10
so it will looks something like
"E:\openttd\openttd.exe -D -d 2 -l 10.1.1.10"

note: the IP address i use for my internal network "10.1.1.10" is the ip address of the computer that is running the above powershell code.
the commandline -l <IP> outputs to a network port which in this case is netcat

if everything is done right, when you run the shortcut, it will load the dedicated server and output everything to the powershell window :)

If you have any questions or need help with this, let me know, I can do my best to assist :D

Post Reply

Return to “OpenTTD Problems”

Who is online

Users browsing this forum: No registered users and 2 guests