Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-01-2007, 03:30 AM   #1
LQ Newbie
Registered: Jul 2005
Distribution: Ubuntu
Posts: 29

Rep: Reputation: 15
Stop process while running script

Hi everyone,

I am trying to get some information out of mplayer. I want to know the length of a video file. I used "-identify" switch it returns a whole bunch of information including something called "ID_LENGTH" which is exactly what I need. Here is what I do in the bash script. (I pass the name of the video file as an argument to the script)

mplayer -identify "$1" 2> /dev/null | grep "ID_LENGTH" > /tmp/out.$$
cat /tmp/out.$$ | cut -d"="  -f2,2
This actually returns the value that I need to get, but the problem is that I need to stop mplayer by hand. The output when I run the script should be the length of the file, without really running the file, so we should exit from mplayer as soon as we get "ID_LENGTH" field so that the script will continue and the length of the file will be outputed on the stdout.

Thanx in advance
Old 07-01-2007, 04:12 AM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
You could run the mplayer process in the background and then use "kill -SIGQUIT %1" to kill it.
mplayer -identify "$1" 2> /dev/null | grep "ID_LENGTH" > /tmp/out.$$ &
sleep 5
cat /tmp/out.$$ | cut -d"="  -f2,2
kill -SIGQUIT %1
I don't know if 5 seconds is enough time to locate the video.


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
How to stop a real time process in a script susee_sundar Linux - Software 4 05-30-2006 07:20 AM
Script to see if a process ir running, if not start it ncsuapex Programming 4 07-03-2005 01:27 PM
Please help easy questions, how do I stop a process from running in SSH? lexington Linux - Newbie 3 05-01-2004 12:03 PM
Continuously running do I stop it? Holly Linux - Newbie 2 02-27-2004 12:39 AM
[script] check for a running process mikshaw Linux - Software 2 01-13-2004 08:33 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:11 AM.

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