I'm executing this script from user root in directory "/":

su -c "sh /home/bob/start_server.sh" bob

and "start_server.sh" contains

screen -d -m -S serverscreen mono startserver.exe

However all the files created by "startserver.exe" are created in the root directory "/", so it fails silently (I guess because of permission problems as it works if I cd to "/home/bob" before calling the "u -c" command line)

I checked the manual for the "su" command, but I didn't find any clues there.

Could it be that the "screen" resets the current directory and executes from "/" instead of "/home/bob"?

  • 1
    I'm not familiar with mono but does this work? screen -d -m -S serverscreen bash -c 'cd /home/bob; mono startserver.exe' – HoD Sep 21 '17 at 6:20
  • Yes this works, same as if I cd to the user directory in the script file. I'm trying to get it to work only with the one command however ;) – NaturalBornCamper Sep 21 '17 at 13:38

Your Answer

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

Browse other questions tagged or ask your own question.