You are not logged in.

#1 2012-02-18 13:24:36

johannesg00
Member
Registered: 2010-11-30
Posts: 74

prevent programm to output on bash

Hello,

i'm writing a script to rip a dvd to my harddisk, but i have one small problem...
Here is a code exampe:

# read disc title
echo "==> read disc title..."
disc_title=`lsdvd | grep "Disc Title:" | cut -c 13-128`
echo "===> disc title: $disc_title"

This works fine, but the programm "lsdvd" always puts "libdvdread: Using libdvdcss version 1.2.11 for DVD access" to my bash output...
Is there a way to prevent this behaviour?

Thank you for your help smile

Offline

#2 2012-02-18 13:34:07

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: prevent programm to output on bash

You can redirect the output of shell programs like this:

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html


ᶘ ᵒᴥᵒᶅ

Offline

#3 2012-02-19 02:13:34

0_0
Member
From: PRC
Registered: 2011-10-31
Posts: 10

Re: prevent programm to output on bash

Try using |& instead of | after lsdvd.


Yes,I am

Offline

#4 2012-02-19 12:32:42

johannesg00
Member
Registered: 2010-11-30
Posts: 74

Re: prevent programm to output on bash

Thank you smile
"|&" works fine wink

But i have one more small problem:
I start mplayer from the script, run it three seconds and then kill it, and search in the output of mplayer for the audio streams. This works well, but i always get the output of the "kill" command...

mplayer dvd://1 -v |& grep -E "^audio stream" &
pid_mplayer=$!
sleep 2
kill $pid_mplayer
#kill $pid_mplayer > /dev/null
#kill $pid_mplayer 2> /dev/null
sleep 1

Here's the output of the script:

audio stream: 0 format: ac3 (5.1) language: en aid: 128.
audio stream: 1 format: ac3 (stereo) language: cs aid: 129.
audio stream: 2 format: ac3 (stereo) language: de aid: 130.
audio stream: 3 format: ac3 (stereo) language: pl aid: 131.
./dvd: Zeile 119:  4276 Exit 1                  mplayer dvd://1 -v 2>&1
      4277 Beendet                 | grep -E "^audio stream"

(sorry, the output is in german, "Zeile" means "line" and "Beendet" means "closed")

Does anybody have an idea how i can prevent this output?

Offline

#5 2012-02-20 05:16:02

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: prevent programm to output on bash

kill $pid_mplayer > /dev/null 2>&1

Offline

#6 2012-02-20 17:58:19

johannesg00
Member
Registered: 2010-11-30
Posts: 74

Re: prevent programm to output on bash

Hello,

i tried that but it doesn't worked...

audio stream: 0 format: ac3 (stereo) language: en aid: 128.
audio stream: 1 format: ac3 (stereo) language: de aid: 129.
./rip: Zeile 104:  2336 Exit 1                  mplayer dvd://$i -v -vo null -ao null -dvd-device $dvd_device 2>&1
      2337 Beendet                 | grep -E "^audio stream"

Offline

#7 2012-02-20 19:31:27

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: prevent programm to output on bash

Oops, sorry.  I think that the error message you are seeing is not from 'kill', but is the stderr output of the script itself; or more correctly, it is the output of the bash process that runs your script.

Therefore, you have to redirect the stderr of your script to /dev/null.

Thus if your script is named 'rip', then run it like this.

$ rip 2> /dev/null

Last edited by rockin turtle (2012-02-20 19:41:28)

Offline

Board footer

Powered by FluxBB