Sketch of situation

I am running a small game server, openttd, on my (headless) raspberry pi 3B. I have been able to play this game, with a huge map, so resources are fine (if you don't mind waiting a bit).

Everytime I run a game, i do so with openttd -D -f to create a new game, and keep it running after i close my SSH connection. Everytime I close a game, i look up the games PID, kill the process, and if I want another game, i start a new one.

Since all that was going smoothly, i decided it was time to automate that repetitive cycle a bit. I started out by filtering the PID of the first command that contained "openttd" out of the ps aux command, like this: ps aux | grep "openttd" | tr -s " " | cut -s -d " " -f 2 | head -n 1. Although not optimal, it works for me. When I tried to test it however, it didn't find any games. When I investigated this, i noticed the following:

My specific problem

Running the command openttd -D -f completes instantly, and with no output. (It should take some time to calculate stuff).

when running openttd -D -f && tail -f ~/.openttd/openttd.cfg nothing happens.
if i run ps aux | grep openttd I don't find any processes.

If i run the command openttd -h which should show (brief) help info, I get no output, and the command completes instantly.

The command is in my path, and is executable. I don't think I changed any config since it ran successfully. I am able to access the man page of the command, and it looks the same as usual.

My generalized question

How do you deal with a command that misbehaves as I described above?
What are things that should be checked?
What are possible causes for this situation?

  • What does type openttd or which openttdgive? Feb 6 '18 at 13:00
  • @GerardH.Pille That made me realise my mistake! Thanks Feb 6 '18 at 13:05
  • You had your own openttd script? Feb 6 '18 at 13:06
  • Yes - rookie mistake... Feb 6 '18 at 13:12
  • No. But I've learned to add the .sh extension to all my scripts. Feb 6 '18 at 13:13

Check if openttd is what you think it is. Execute

type openttd


which openttd

Thanks to Gerard H. Pille, who suggested to check the command path with type openttd or which openttd, I was able to track the source of my error: myself.

When I tried to automate the process of launching/stopping a game, I created a file called "openttd" in /usr/local/bin. The file was executable, but had no content, hence my error.

Renaming the file to something else fixed my issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.