0

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?

pawel_winzig
  • 902
  • 9
  • 28

1 Answers1

1

2>&1 - This actually redirects STDERR to STDOUT

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

out=`echo sleep 10 | qsub 2>/dev/null`
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
Rawkode
  • 21,990
  • 5
  • 38
  • 45