Running php via unix script

I have a shell script.

#!/bin/bash

# a shell script that keeps looping until an exit code is given

nice php -q -f ./data.php -- $@
ERR=$?

exec $0 $@

I have a few doubts

  • What is $0and what$@
  • what is ERR=$?
  • what does -- $@the 5th row
  • I wanted to know if I can pass data.php as a parameter. so I only have a shell script for all kinds of execution. Let's say I want to run "sh ss.sh data1.php", then this should start data1.php, if I run "ss ss.sh data2.php", it should start data2.php -
+3
source share
2 answers

1) $0is the name of the executable file (the script in your case, for example: if your script is called start_me, then $0is start_me)

2) ERR=$?receives a return codenice php -q -f ./data.php -- $@

3) -- $@ , , php, data.php $@ script ./data.php (, ./your_script_name foo bar nice php -q -f ./data.php -- foo bar)

4) , script

 YOUR_FILE=$1
 shift #this removes the first argument from $@
 nice php -q -f ./$YOUR_FILE -- $@
+1
$0 

- script.

$@ 

- , script

ERR=$? 

php_command="php -q -f $1"
shift
nice $php_command -- $@

f, .

0

All Articles