0

I'm attempting to start a new screen from a PHP script using shell_exec(), the command I'm running is using sudo, i.e sudo screen -dmS [name] .... while I am able to kill screens using sudo screen -S [name] -X quit perfectly fine, I am unable to create a new screen with a given name, any ideas on why? (I've added my user to sudoers btw)

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

0

Firstly, if you are executing a script, make sure that script has the execute flag set, if required; if not the issue which I do not suspect....

This is highly likely an issue with your environment PATH.

When you start a new screen session with your program to run, you are spawning a new environment with the default session settings; what this means is that neither your .bashrc nor .profile or any shell customization scripts will run before starting the script.

My assumption here is that your script is bombing out with a path that exists in your user PATH, but not on the PATH of the screen session. Either redefine the search path, or fully qualify the path to all executables used within the script.

Try launching screen with -L

This will create a file screenlog.0 in your present working directory, this will contain the contents of stderr and stdout from the screen session, even if it quits abruptly.

screen -dmLS anything /path/to/script
cat ./screenlog.0
Matt Clark
  • 27,671
  • 19
  • 68
  • 123
  • Alright so I've done this and it reads `This account is currently not available` – Stan Vanderban Feb 17 '18 at 04:49
  • @StanVanderban Are you trying to do something _as a different user_? Check that user's login shell ( /etc/passwd ) If it's set to something like /bin/false, it's that way for a reason. Maybe create a new named user for your specific application? – Matt Clark Feb 17 '18 at 04:59