Pregunta

I'm using a server with PBS. I'm testing it with

echo sleep 10 | qsub

At the moment there is a problem with the server and an error message is returned. By redirecting this error message

echo sleep 10 | qsub 2>&1

nothing will be printed.

Now I would like to put this into a shell script and save the output in a variable:

out=`echo sleep 10 | qsub 2>&1`

However, although I'm redirecting the error message using 2>&1, the variable out still contains the error message. What am I doing wrong?

¿Fue útil?

Solución

2>&1 - This actually redirects STDERR to STDOUT

What you're after is 2>/dev/null

out=`echo sleep 10 | qsub 2>/dev/null`
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top