LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-09-2013, 05:52 PM   #1
stripe
LQ Newbie
 
Registered: Nov 2011
Posts: 22

Rep: Reputation: Disabled
bash problem


hi all
anyone know the best place to post a bash scripting question on this forum?

cheers

stripe
 
Old 06-09-2013, 05:59 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,830

Rep: Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409
Programming ? maybe

But what is this question ?
 
Old 06-09-2013, 06:07 PM   #3
stripe
LQ Newbie
 
Registered: Nov 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
I am trying to use an error statement from the output of a terminal generated by a program (vlc) in an if statement to trigger an exit trap to cleanly exit the bash script.

the error message i want to use is added below the script.
cheers

http://pastebin.com/zpdw7Ycz
 
Old 06-09-2013, 07:28 PM   #4
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
you could test the exit code of cvlc like this

Code:
cvlc "$@"
if [ "$?" != "0" ];
then
    exit
fi
The above if is not very smart
Code:
cvlc "$@";cvlc_exit=$?
if [ "$cvlc_exit" != "0" ];
then
    echo "cvlc \"$@\" failed with exitcode $cvlc_exit"
    exit
fi
Better, but a case statement would give you more control ( assuming you have a list of exit codes from the source/docs )
 
Old 06-09-2013, 07:41 PM   #5
stripe
LQ Newbie
 
Registered: Nov 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
thanks for good the answers but the problem is cvlc/vlc is not exiting if the player window is closed manualy before it is finiheg it still runs in the background and the only output from the terminal when the window is closedare tgeese two lines:

***[0xad4046f0] xcb_window window error: X server failure
xdg-screensaver: Window 0x03400000 does not exist***

and i cant find a way to use that code to trigger an exit trap

hope this makes sense as ist only my second script

thanks again
 
Old 06-09-2013, 09:28 PM   #6
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
Ahh, yes I miss-understood


OK , I really don't like this .. but one way to do it

Code:
coproc cvlc "$@" 2> cvlc.log
while [ $COPROC_PID ];do
    grep -q "xcb_window window error" cvlc.log && kill $COPROC_PID ; sleep 10 || sleep 10
done
you will want to put the log somewhere 'clean' instead of the working dir as above put you get the idea

I never liked vlc so I never use it
Any reason you can't use mplayer?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash problem : -bash: [: /bin/bash: unary operator expected J.A.X Linux - Software 1 09-22-2011 06:52 AM
[SOLVED] bash : getopts problem in bash script. angel115 Programming 2 03-02-2009 11:53 AM
Reading a bash variable in bash scripting problem freeindy Programming 3 11-27-2008 03:29 AM
Problem with BASH Pheidon Linux From Scratch 5 06-24-2005 03:34 AM
bash problem Vincent Slackware 2 10-30-2003 06:01 AM


All times are GMT -5. The time now is 10:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration