Register
It is currently Fri Sep 19, 2014 1:45 am

Stopping command [SOLVED]


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Sat Feb 12, 2011 11:47 am   
User avatar

Joined: Sat Jan 22, 2011 11:42 am
Posts: 7
Location: Ljubljana, Slovenia
Ola

I am still new to bash, and I already made several scripts ;)
I use zenity for running my scripts.


Right now I made script that records from my webcam, but,
it needs to be run in terminal in order to ctrl+c to stop recording.

My script:
Code:
#!/bin/bash
kam=$(zenity --title "Shrani kot (.avi dodaj na koncu):" --file-selection --save --confirm-overwrite);
mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -nosound -ovc lavc -o $kam
exit


How can I stop already running command using... , well, using what?

Thank you.


Last edited by Seiduna on Thu Feb 24, 2011 1:31 am, edited 1 time in total.

Top
 Profile  
 PostPosted: Sun Feb 13, 2011 1:23 am   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
Am I right in assuming you want to stop your mencoder process with zenity as well? In that case you can try something like this:
Code:
#!/bin/bash

## get filename
kam=$(zenity --title "Shrani kot (.avi dodaj na koncu):" --file-selection --save --confirm-overwrite)

## run mencoder as background process
mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -nosound -ovc lavc -o "$kam" &

## get process id from mencoder
pid=$!

## kill mencoder with zenity.
zenity --question --text="Stop recording?" && kill $pid

## wait until mencoder process is finished
wait


Top
 Profile  
 PostPosted: Mon Feb 14, 2011 9:28 am   
User avatar

Joined: Sat Jan 22, 2011 11:42 am
Posts: 7
Location: Ljubljana, Slovenia
Hello Patsie,

I am using Gentoo and I took me a whole weekend to clear the mess that new xfce upgrade brought...
Right now my cheese and camorama is not working as it should...

Nevertheless your script is running flawlessly!

I see that you forced the recording in background,
(I did not know that, but I looked it up,
comes in handy, like firefox &, and than I go working on in same shell)
than you get PID of recording,
(I had same idea, but did not know the sintax, and I did look...)
and than popup the question to stop recording...
Man, you are right on!!!

I am building a similar script for voice recording, and your script will be implemented.

Thank you.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP