LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   cp 8.19: running it in the background, does it show the errors on the foreground? (http://www.linuxquestions.org/questions/slackware-14/cp-8-19-running-it-in-the-background-does-it-show-the-errors-on-the-foreground-4175507197/)

stf92 06-05-2014 08:59 PM

cp 8.19: running it in the background, does it show the errors on the foreground?
 
Hi: If I do
Code:

cp -r dir_A dir_B &
. Do I see the errors (stderr) on the screen (foreground)?

TracyTiger 06-05-2014 09:10 PM

Quote:

Originally Posted by stf92 (Post 5183284)
Hi: If I do
Code:

cp -r dir_A dir_B &
. Do I see the errors (stderr) on the screen (foreground)?

Do you?

Why don't you cause an error when running the command and then you will see if the errors appear on the screen.

stf92 06-05-2014 10:02 PM

Quote:

Originally Posted by stf92 (Post 5183284)
Hi: If I do
Code:

cp -r dir_A dir_B &
. Shall I see the errors (stderr) on the screen (foreground)?

[Edited by the author]

jprzybylski 06-05-2014 10:19 PM

Quote:

Originally Posted by stf92 (Post 5183284)
Hi: If I do
Code:

cp -r dir_A dir_B &
. Do I see the errors (stderr) on the screen (foreground)?

Yes, you will. To test, try something like this:
Code:

{ sleep 2; cp -r test.file imaginary/directory/that/does/not/exist; } &
This will spit an error in 2 seconds, despite being in the background.

TracyTiger 06-05-2014 11:09 PM

@stf92 - In case you didn't know this ... If you don't want the errors to go to the screen and you're using bash you can redirect them by modifying the example jprzybylski gave to ...

Code:

{ sleep 2; cp -r test.file imaginary/directory/that/does/not/exist 2> /tmp/errorlog.txt; } &
File descriptor '2' is the stderr you mentioned in your post.

If you use the man page for bash and search for REDIRECTION you'll find more information.

stf92 06-05-2014 11:09 PM

Quote:

Originally Posted by TracyTiger (Post 5183294)
Do you?

Why don't you cause an error when running the command and then you will see if the errors appear on the screen.

I already did it via
Code:

cp -r dir_A dir_B 2>&1 | less
I made a fool of myself.My intention was to get rid of the errors. Thank you TracyTiger.


All times are GMT -5. The time now is 08:27 PM.