LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 07-01-2007, 03:30 AM   #1
azazel11998
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)

Code:
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
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You could run the mplayer process in the background and then use "kill -SIGQUIT %1" to kill it.
Code:
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.
 
  


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
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 process...how 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


All times are GMT -5. The time now is 07:33 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration