문제

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?

도움이 되었습니까?

해결책

2>&1 - This actually redirects STDERR to STDOUT

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

out=`echo sleep 10 | qsub 2>/dev/null`
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top