0

I'm running a Half-Life dedicated server on my VPS with following bash file named startserver in HLDS:

#!/bin/bash
screen -A -m -d -S hlds ./hlds_run -console -game valve -ip **ip address** -port 27015 +maxplayers 16 +map crossfire > /dev/null >&1 &

So I type ./startserver and my server is running. I'm not owner of this code, I just copied it. And I tried to make this code work for a PHP file and I created a directory named "test" and I have "test.php" code so that I can run my php file by typing "php test.php" but I need to run it on a screen too, because I'm not always gonna run the putty client.

I tried to edit the code in the directory where my php file exists and that's what I got inside:

#!/bin/bash screen -AmdS phper php test.php > test.txt >&1 &

I supposed to create a screen named "phper" and run the test.php inside. All files exist in the directory but I face with that error:

/bin/bash: screen -AmdS phper php test.php > test.txt >&1 &: No such file or directory

Am I doing something wrong?

Walker
  • 131
  • 2
  • 16
  • 1
    You lost line separator, the first line should be `#!/bin/bash` and screen should be on second line. – osgx Jul 10 '16 at 09:09

1 Answers1

1

The first line is wrong, if it is one line

#!/bin/bash screen -AmdS phper php test.php > test.txt >&1 &

First line of text file with executable bit set may begin with "#!" to set interpreter of the file, it is called Shebang. When you run the script and there is shebang, linux kernel will recognize it and start interpreter with the name of script as its argument.

You should not add anything after "/bin/bash", or it will try to parse it as his own parameters, and there is no bash parameter "screen" and no file with name "screen" (and with bash script inside) in current directory.

So, try put bash in shebang on first line and actual bash script from second line:

 #!/bin/bash 
 screen -AmdS phper php test.php > test.txt >&1 &
osgx
  • 90,338
  • 53
  • 357
  • 513