Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "Ambiguous output redirect" mean?

Tags:

shell

php

unix

I have a PHP script that I want to call on some form action.

This command works fine:

/usr/local/bin/php -q script.php > /dev/null 2>&1 &

But it all go wrong when I add arguments in the command:

/usr/local/bin/php -q script.php --var=value > /dev/null 2>&1 &

it returns "Ambiguous output redirect".

I have read this http://www.xaprb.com/blog/2006/06/06/what-does-devnull-21-mean/ article too, and have tried almost everything possible as far as I can understand, and still have no idea how to fix it.

Please help me.

like image 815
Gohar SUltan Avatar asked Aug 02 '11 11:08

Gohar SUltan


People also ask

What is ambiguous redirect?

If your script's redirect contains a variable, and the script body defines that variable in a section enclosed by parenthesis, you will get the "ambiguous redirect" error.

What does 2 >& 1 mean and when is it typically used?

&1 is used to reference the value of the file descriptor 1 (stdout). Now to the point 2>&1 means “Redirect the stderr to the same place we are redirecting the stdout” Now you can do this.


1 Answers

I assume you're using csh or one of its variants, use:

... >&/dev/null
like image 63
Karoly Horvath Avatar answered Sep 25 '22 15:09

Karoly Horvath