Bash script- capture cdparanoia text output
I'm new to linux, and am writing a bash script to automate the ripping/encoding process to backup my cd collection. My script is working very well. One thing I would like to add is the ability to add the cdparanoia version number to my log file. I know cdparanoia hasn't been updated in years, but this is more for learning than anything. I can't seem to capture the output of "cdparanoia -V". Even when I try to pipe it to a var in my script, it seems to print to the console no matter what. Am I doing something wrong?
|
did you already tried to redirect stderr to stdout:
Code:
program 2>&1 | other commands |
It could be writing the info to stderr instead of stdout. Have you tried this:
Code:
cdparanoia -V > logfile 2>&1 |
Thanks for the quick reply, I'll give it a try...Can you provide a syntax to capture stderr output into a variable?
|
Code:
var=$(cdparanoia 2>&1) |
It worked! Thanks! ...But why would (what seems to be) standard output be stderr?
|
It just depends on the program. If you want you can ask the cdparanoia devs. ;)
|
Quote:
As far as why they look like the same thing goes, that just means that the current location for stdout was the same as for stderr. Try running ls -l /dev/stdout and ls -l /dev/stderr from a terminal and following the links. On the ssh window I have open at the moment, the output is: Code:
$ ls -l /dev/stdout |
All times are GMT -5. The time now is 07:36 AM. |