1

I found this line in a project:

exec('php '.$myPath."/somefile.php bah blha blha --myparam=$param > /dev/null 2>&1 < /dev/null &";)

What does this line mean?

I know that it runs a somefile.php with parameter myparam, but that are these parts: /dev/null 2>&1 < /dev/null & , bah blha blha ?

rinchik
  • 2,642
  • 8
  • 29
  • 46
  • `/dev/null` send output to /dev/null; `2>&1` send error output to the same place as output; `< /dev/null` take input from /dev/null; and `bah blha blha` are command line arguments passed to the php script – Mark Baker Apr 10 '13 at 19:10
  • It's about redirecting output and input. There's a good explanation on AskUbuntu. http://stackoverflow.com/questions/10508843/what-is-dev-null-21 – Ed Manet Apr 10 '13 at 19:13

2 Answers2

2

All the syntax in question is bash syntax. You can start here to learn more.

However, here comes a little explanation:

> /dev/null

means that the output is redirected to /dev/null what means that the output of the program will be thrown away

2>&1

means that stderr is redirected to stdout. As stdout is thrown away errors will be thrown away too.

< /dev/null

means that /dev/null is piped to stdin of the program - what is actually nothing.

&

at the end of the line means, that the program should run in background what makes exec return immediately

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
1

/dev/null is a black hole and it seems both the results sent to STDOUT (standard out, usually your screen) and STDERR (standard error) to the black hole. So in summary, it does nothing.

ebadedude
  • 161
  • 8