Linux Newbie help
 help / color / mirror / Atom feed
* scripting the "rec" function for a fixed time.
@ 2003-02-25  0:01 Peter Howell
  2003-02-25  2:55 ` Ray Olszewski
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Peter Howell @ 2003-02-25  0:01 UTC (permalink / raw)
  To: linux-newbie

I would like to be able to run the rec command unattended.  Right now
when executed, it will record sound until I hit C-c.  I would really
like to be able to right a script which will execute "rec ...", then
wait a specified period of time, then pass the C-c to it.  Or is there a
simpler way?

Thanks

Peter

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripting the "rec" function for a fixed time.
  2003-02-25  0:01 scripting the "rec" function for a fixed time Peter Howell
@ 2003-02-25  2:55 ` Ray Olszewski
  2003-02-25  6:14   ` pa3gcu
  2003-02-25  7:01 ` Elias Athanasopoulos
  2003-03-08  0:22 ` whitnl73
  2 siblings, 1 reply; 10+ messages in thread
From: Ray Olszewski @ 2003-02-25  2:55 UTC (permalink / raw)
  To: linux-newbie

At 07:01 PM 2/24/2003 -0500, Peter Howell wrote:
>I would like to be able to run the rec command unattended.  Right now
>when executed, it will record sound until I hit C-c.  I would really
>like to be able to right a script which will execute "rec ...", then
>wait a specified period of time, then pass the C-c to it.  Or is there a
>simpler way?


I waited to see if anyone else would respond, since I cannot actually 
answer your question.

"rec" is not a stock linux command, and I cannot readily identify a package 
that includes that application (just trying to match on "rec" turns up 
several hundred hits in the Debian package database). So I'd suggest you 
tell us a bit more about your setup, including enough information that we 
can identify and take a look at the package that includes this command.

What file format does it record to, and does it record from standard 
sound-card devices (like /dev/mixer or /dev/dsp)? Does its man page list 
any command-line arguments (many video recording programs, for example, 
accept a flag like "-t 5m" to specify recording time)?

Writing a script of the sort you have in mind is a bit more complicated 
than you might at first think, so you are wise to look for other options.




-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripting the "rec" function for a fixed time.
  2003-02-25  2:55 ` Ray Olszewski
@ 2003-02-25  6:14   ` pa3gcu
  2003-02-26  0:44     ` Peter Howell
  0 siblings, 1 reply; 10+ messages in thread
From: pa3gcu @ 2003-02-25  6:14 UTC (permalink / raw)
  To: linux-newbie

On Tuesday 25 February 2003 02:55, Ray Olszewski wrote:
> At 07:01 PM 2/24/2003 -0500, Peter Howell wrote:
> >I would like to be able to run the rec command unattended.  Right now
> >when executed, it will record sound until I hit C-c.  I would really
> >like to be able to right a script which will execute "rec ...", then
> >wait a specified period of time, then pass the C-c to it.  Or is there a
> >simpler way?
>
> I waited to see if anyone else would respond, since I cannot actually
> answer your question.

I can shed some light.

>
> "rec" is not a stock linux command, and I cannot readily identify a package
> that includes that application (just trying to match on "rec" turns up
> several hundred hits in the Debian package database). So I'd suggest you
> tell us a bit more about your setup, including enough information that we
> can identify and take a look at the package that includes this command.

rec is an unix command altho' not well supported, slackware 8 has it included.

rec --help shows a lot but thses are relavant to the question;
  -c, --channels=CHANNELS      specifies the number of sound channels in FILE
  -d, --device=DEVICE          use DEVICE for input/output
  -f, --format=FORMAT          specifies bit format of sample
                               FORMAT is either s, u, U, A, a, or g
  -r, --rate=RATE              sample rate in hertz of FILE
  -s, --size=SIZE              interpret size of sample

I think this one could be an help -s xxxxxxxb
                               SIZE is either b, w, l, f, d, or D
  -t, --type=TYPE              specifies file format of FILE

Now you could use trail and error and see how big one song is and then define 
the byte size.
rec should then exit without crtl-c.

> What file format does it record to, and does it record from standard
> sound-card devices (like /dev/mixer or /dev/dsp)? Does its man page list
> any command-line arguments (many video recording programs, for example,
> accept a flag like "-t 5m" to specify recording time)?
>
> Writing a script of the sort you have in mind is a bit more complicated
> than you might at first think, so you are wise to look for other options.

Agreed.

-- 
Regards Richard
pa3gcu@zeelandnet.nl
http://people.zeelandnet.nl/pa3gcu/

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripting the "rec" function for a fixed time.
  2003-02-25  0:01 scripting the "rec" function for a fixed time Peter Howell
  2003-02-25  2:55 ` Ray Olszewski
@ 2003-02-25  7:01 ` Elias Athanasopoulos
  2003-03-08  0:22 ` whitnl73
  2 siblings, 0 replies; 10+ messages in thread
From: Elias Athanasopoulos @ 2003-02-25  7:01 UTC (permalink / raw)
  To: Peter Howell; +Cc: linux-newbie

On Mon, Feb 24, 2003 at 07:01:03PM -0500, Peter Howell wrote:
> I would like to be able to run the rec command unattended.  Right now
> when executed, it will record sound until I hit C-c.  I would really
> like to be able to right a script which will execute "rec ...", then
> wait a specified period of time, then pass the C-c to it.  Or is there a
> simpler way?

It's morning here and in 5mins I'm going to have exams in Quantum Mechanics
so my reply will be quite theoritical. :-)

The solution may not be the optimal: just use at to kill rec after the 
specified time. Read the man page of at(1) for the details.

Elias

-- 
University of Athens			I bet the human brain 
Physics Department				is a kludge --Marvin Minsky 

	
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripting the "rec" function for a fixed time.
  2003-02-25  6:14   ` pa3gcu
@ 2003-02-26  0:44     ` Peter Howell
  2003-02-26  6:01       ` pa3gcu
                         ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Peter Howell @ 2003-02-26  0:44 UTC (permalink / raw)
  To: pa3gcu; +Cc: linux-newbie


On Tue, 2003-02-25 at 01:14, pa3gcu wrote:
> > "rec" is not a stock linux command, and I cannot readily identify a package
> > that includes that application (just trying to match on "rec" turns up
> > several hundred hits in the Debian package database). So I'd suggest you
> > tell us a bit more about your setup, including enough information that we
> > can identify and take a look at the package that includes this command.
> 
> rec is an unix command altho' not well supported, slackware 8 has it included.
> 
> rec --help shows a lot but thses are relavant to the question;
>   -c, --channels=CHANNELS      specifies the number of sound channels in FILE
>   -d, --device=DEVICE          use DEVICE for input/output
>   -f, --format=FORMAT          specifies bit format of sample
>                                FORMAT is either s, u, U, A, a, or g
>   -r, --rate=RATE              sample rate in hertz of FILE
>   -s, --size=SIZE              interpret size of sample
> 
> I think this one could be an help -s xxxxxxxb
>                                SIZE is either b, w, l, f, d, or D

	Alas no :-(
	size isn't the file size.  It's really the width of each sample.  eg b
for 8 bits, w for 16 bits....

It appears that rec does not buffer the sound, but instead writes it
directly to the file.  
It's inelegant, but I suppose I could kill the application after a
specified delay.  There are two problems with implementing that for me. 
Firstly, I don't think I could do that in perl, which I'm most familiar
with because there doesn't appear to be an easy way to spawn a process
and continue running the scipt.  Secondly, I don't know how to run a
process and get it's process id, which I'd need to kill it. 

	Ok, just did a little rtfm.  I guess I could use ps and extract the id.
Now I guess I'd better learn some bash scripting


-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripting the "rec" function for a fixed time.
  2003-02-26  0:44     ` Peter Howell
@ 2003-02-26  6:01       ` pa3gcu
  2003-02-26  8:08       ` Elias Athanasopoulos
  2003-02-26 10:19       ` Carl
  2 siblings, 0 replies; 10+ messages in thread
From: pa3gcu @ 2003-02-26  6:01 UTC (permalink / raw)
  To: Peter Howell; +Cc: linux-newbie

On Wednesday 26 February 2003 00:44, Peter Howell wrote:

> It appears that rec does not buffer the sound, but instead writes it
> directly to the file.

OK, i should have mentioned that i dont use the program myself.

> It's inelegant, but I suppose I could kill the application after a
> specified delay.  There are two problems with implementing that for me.
> Firstly, I don't think I could do that in perl, which I'm most familiar
> with because there doesn't appear to be an easy way to spawn a process
> and continue running the scipt.  Secondly, I don't know how to run a
> process and get it's process id, which I'd need to kill it.
>
> 	Ok, just did a little rtfm.  I guess I could use ps and extract the id.
> Now I guess I'd better learn some bash scripting

Do both at once, get pid(s) of rec and kill it/them.

kill `ps aux | grep rec | grep -v grep | awk '{print $2}'`

-- 
Regards Richard
pa3gcu@zeelandnet.nl
http://people.zeelandnet.nl/pa3gcu/

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripting the "rec" function for a fixed time.
  2003-02-26  0:44     ` Peter Howell
  2003-02-26  6:01       ` pa3gcu
@ 2003-02-26  8:08       ` Elias Athanasopoulos
  2003-02-26 10:19       ` Carl
  2 siblings, 0 replies; 10+ messages in thread
From: Elias Athanasopoulos @ 2003-02-26  8:08 UTC (permalink / raw)
  To: Peter Howell; +Cc: pa3gcu, linux-newbie

On Tue, Feb 25, 2003 at 07:44:08PM -0500, Peter Howell wrote:
> 	Ok, just did a little rtfm.  I guess I could use ps and extract the id.
> Now I guess I'd better learn some bash scripting

You can use pkill, too; it uses process names instead of ids.

Elias

-- 
University of Athens			I bet the human brain 
Physics Department				is a kludge --Marvin Minsky 

	
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripting the "rec" function for a fixed time.
  2003-02-26  0:44     ` Peter Howell
  2003-02-26  6:01       ` pa3gcu
  2003-02-26  8:08       ` Elias Athanasopoulos
@ 2003-02-26 10:19       ` Carl
  2003-02-26 17:26         ` Eric
  2 siblings, 1 reply; 10+ messages in thread
From: Carl @ 2003-02-26 10:19 UTC (permalink / raw)
  To: Peter Howell; +Cc: linux-newbie

At 19:44 25/02/2003 -0500, Peter Howell wrote:

>On Tue, 2003-02-25 at 01:14, pa3gcu wrote:
>> > "rec" is not a stock linux command, and I cannot readily identify a package
>> > that includes that application (just trying to match on "rec" turns up
>> > several hundred hits in the Debian package database). So I'd suggest you
>> > tell us a bit more about your setup, including enough information that we
>> > can identify and take a look at the package that includes this command.
>> 
>> rec is an unix command altho' not well supported, slackware 8 has it included.
>> 
>> rec --help shows a lot but thses are relavant to the question;
>>   -c, --channels=CHANNELS      specifies the number of sound channels in FILE
>>   -d, --device=DEVICE          use DEVICE for input/output
>>   -f, --format=FORMAT          specifies bit format of sample
>>                                FORMAT is either s, u, U, A, a, or g
>>   -r, --rate=RATE              sample rate in hertz of FILE
>>   -s, --size=SIZE              interpret size of sample
>> 
>> I think this one could be an help -s xxxxxxxb
>>                                SIZE is either b, w, l, f, d, or D
>
>        Alas no :-(
>        size isn't the file size.  It's really the width of each sample.  eg b
>for 8 bits, w for 16 bits....
>
>It appears that rec does not buffer the sound, but instead writes it
>directly to the file.  
>It's inelegant, but I suppose I could kill the application after a
>specified delay.  There are two problems with implementing that for me. 
>Firstly, I don't think I could do that in perl, which I'm most familiar
>with because there doesn't appear to be an easy way to spawn a process
>and continue running the scipt.  Secondly, I don't know how to run a
>process and get it's process id, which I'd need to kill it. 
>
>        Ok, just did a little rtfm.  I guess I could use ps and extract the id.
>Now I guess I'd better learn some bash scripting
>


There is a tcl based interpreter called expect which lets you spawn processes and gives you it's pid
easily. If you have any programming or scripting experience then it will be easy.

Or there is a program called timelimit which is part of the netpipes package that spawns a process
and kills it if it doesn't return after a specified time.

I don't know how accurate these are and i have no experience of timelimit.

--
Carl

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripting the "rec" function for a fixed time.
  2003-02-26 10:19       ` Carl
@ 2003-02-26 17:26         ` Eric
  0 siblings, 0 replies; 10+ messages in thread
From: Eric @ 2003-02-26 17:26 UTC (permalink / raw)
  To: Carl, Peter Howell; +Cc: linux-newbie

On Wednesday 26 February 2003 04:19 am, Carl wrote:
> At 19:44 25/02/2003 -0500, Peter Howell wrote:
> >On Tue, 2003-02-25 at 01:14, pa3gcu wrote:
> >> > "rec" is not a stock linux command, and I cannot readily identify a
> >> > package that includes that application (just trying to match on "rec"
> >> > turns up several hundred hits in the Debian package database). So I'd
> >> > suggest you tell us a bit more about your setup, including enough
> >> > information that we can identify and take a look at the package that
> >> > includes this command.
> >>
> >> rec is an unix command altho' not well supported, slackware 8 has it
> >> included.
> >>
> >> rec --help shows a lot but thses are relavant to the question;
> >>   -c, --channels=CHANNELS      specifies the number of sound channels in
> >> FILE -d, --device=DEVICE          use DEVICE for input/output
> >>   -f, --format=FORMAT          specifies bit format of sample
> >>                                FORMAT is either s, u, U, A, a, or g
> >>   -r, --rate=RATE              sample rate in hertz of FILE
> >>   -s, --size=SIZE              interpret size of sample
> >>
> >> I think this one could be an help -s xxxxxxxb
> >>                                SIZE is either b, w, l, f, d, or D
> >
> >        Alas no :-(
> >        size isn't the file size.  It's really the width of each sample. 
> > eg b for 8 bits, w for 16 bits....
> >
> >It appears that rec does not buffer the sound, but instead writes it
> >directly to the file.
> >It's inelegant, but I suppose I could kill the application after a
> >specified delay.  There are two problems with implementing that for me.
> >Firstly, I don't think I could do that in perl, which I'm most familiar
> >with because there doesn't appear to be an easy way to spawn a process
> >and continue running the scipt.  Secondly, I don't know how to run a
> >process and get it's process id, which I'd need to kill it.
> >
> >        Ok, just did a little rtfm.  I guess I could use ps and extract
> > the id. Now I guess I'd better learn some bash scripting
>
> There is a tcl based interpreter called expect which lets you spawn
> processes and gives you it's pid easily. If you have any programming or
> scripting experience then it will be easy.
>
> Or there is a program called timelimit which is part of the netpipes
> package that spawns a process and kills it if it doesn't return after a
> specified time.
>
> I don't know how accurate these are and i have no experience of timelimit.

I am not sure if I am correct, but its worth a try:

If you are interested in scripting it I once had to do something similiar in 
BASH. By creating a function, it will execute the function commands in a 
subshell while continuing with the current script. Try something like this

#!/bin/bash
function boot ()
{
	*RecordProgram Command Here*&
}
boot 			#calls the funtion boot.
let PID = $!	#returns PID of last executed background command.
wait 9000  		#let it run for 9000 seconds
kill $PID

Something like that. this is opposed to the example below where the background 
ampersand will hang the script. If $! doesnt return the correct pid then you 
might be able to fake it using awk.grep and the ps command to isolate the pid 
column.

#!/bin/bash
Recordprogram&
letPID = $!
wait 9000
kill $PID

I believe the function wont hang the script waiting for input like the above 
example. Let me know if this sounds logical. I would appreciate input from 
any real bash programmers to see if I am correct. As always, best of luck!
#------------------------
#Eric Bambach   
#Eric@CISU.net 
#------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: scripting the "rec" function for a fixed time.
  2003-02-25  0:01 scripting the "rec" function for a fixed time Peter Howell
  2003-02-25  2:55 ` Ray Olszewski
  2003-02-25  7:01 ` Elias Athanasopoulos
@ 2003-03-08  0:22 ` whitnl73
  2 siblings, 0 replies; 10+ messages in thread
From: whitnl73 @ 2003-03-08  0:22 UTC (permalink / raw)
  To: p.howell74; +Cc: linux-newbie

On 24 Feb 2003, Peter Howell wrote:

> I would like to be able to run the rec command unattended.  Right now
> when executed, it will record sound until I hit C-c.  I would really
> like to be able to right a script which will execute "rec ...", then
> wait a specified period of time, then pass the C-c to it.  Or is there a
> simpler way?
>
> Thanks
>
> Peter

I don't have rec or any hardware to do with sound, so I'll use "yes"
to demonstrate a program that runs until interrupted.  Not I use SIGHUP
rather than SIGINT, as bash provides a handler for SIGINT for background
jobs.  stdout and stderr don't have to be null, but they have to be
directed away from the terminal.

#!/bin/sh
yes >/dev/null 2>/dev/null &
sleep 1
kill -HUP $!


Lawson
--
---oops---



________________________________________________________________
Sign Up for Juno Platinum Internet Access Today
Only $9.95 per month!
Visit www.juno.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-03-08  0:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-25  0:01 scripting the "rec" function for a fixed time Peter Howell
2003-02-25  2:55 ` Ray Olszewski
2003-02-25  6:14   ` pa3gcu
2003-02-26  0:44     ` Peter Howell
2003-02-26  6:01       ` pa3gcu
2003-02-26  8:08       ` Elias Athanasopoulos
2003-02-26 10:19       ` Carl
2003-02-26 17:26         ` Eric
2003-02-25  7:01 ` Elias Athanasopoulos
2003-03-08  0:22 ` whitnl73

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox