Can I change the background of the blog?
Shell Script Question
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• RYXI
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

RYXI > Linux > Shell Script Question 18 September 2007 22:16:01

  Recent blog posts: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

Shell Script Question

David Lightman 18 September 2007 22:16:01
 I am trying to write my first real script, and I have a problem. I
simply want to record 1 second of audio to a file, and do so on an
automated basis. My script is:

rec sample.au &
sleep 1s
kill -INT $!

The problem is that the process "sox" still runs after my script
executes and the output file is corrupt. Any help on this would be
appreciated.
Add comment
Heinz-Jrgen Oertel 27 August 2005 16:39:00 permanent link ]
 David Lightman wrote:
I am trying to write my first real script, and I have a problem. I
simply want to record 1 second of audio to a file, and do so on an
automated basis. My script is:
rec sample.au &
sleep 1s
kill -INT $!
The problem is that the process "sox" still runs after my script
executes and the output file is corrupt. Any help on this would be
appreciated.


Are you sure SIGINT is handled correctly by 'rec' ?
Can you kill it by issuing the command at the command line?
Look if it is a matter of the 'rec' or may be a wrong PID in $!

Heinz

Add comment
David Lightman 27 August 2005 17:47:42 permanent link ]
 Heinz-JГјrgen Oertel wrote:
David Lightman wrote:
I am trying to write my first real script, and I have a problem. I
simply want to record 1 second of audio to a file, and do so on an
automated basis. My script is:
rec sample.au &
sleep 1s
kill -INT $!
The problem is that the process "sox" still runs after my script
executes and the output file is corrupt. Any help on this would be
appreciated.
Are you sure SIGINT is handled correctly by 'rec' ?
Can you kill it by issuing the command at the command line?
Look if it is a matter of the 'rec' or may be a wrong PID in $!
Heinz

rec sample.au
(manually wait 1 sec)
<CTRL-C>

That works like I want, and I am just trying to script that.

$! seems to be the correct PID.

I thought SIGINT was supposed to be the same as <CTRL-C>. I think,
based on what I am seing here, it may not be......
Add comment
Heinz-JГјrgen Oertel 27 August 2005 19:44:04 permanent link ]
 David Lightman wrote:
Heinz-JГјrgen Oertel wrote:
David Lightman wrote:
I am trying to write my first real script, and I have a problem. I
simply want to record 1 second of audio to a file, and do so on an
automated basis. My script is:
rec sample.au &
sleep 1s
kill -INT $!
The problem is that the process "sox" still runs after my script
executes and the output file is corrupt. Any help on this would be
appreciated.
Are you sure SIGINT is handled correctly by 'rec' ?
Can you kill it by issuing the command at the command line?
Look if it is a matter of the 'rec' or may be a wrong PID in $!
Heinz
(manually wait 1 sec)
<CTRL-C>
That works like I want, and I am just trying to script that.
$! seems to be the correct PID.
I thought SIGINT was supposed to be the same as <CTRL-C>. I think,
based on what I am seing here, it may not be......


Yes SIGINT is the Signal what should be received entering ^C from stdin.
What happens if you try

rec sample.au < /dev/null > /dev/null


and may be directing stderr as well to /dev/null.
The exact syntax depends on the used shell.
You never talked about the system and tools you are using.

Heinz


Add comment
Ari Rankum 28 August 2005 01:54:46 permanent link ]
 David Lightman wrote:
Heinz-JГјrgen Oertel wrote:
David Lightman wrote:
I am trying to write my first real script, and I have a problem. I
simply want to record 1 second of audio to a file, and do so on an
automated basis. My script is:
rec sample.au &
sleep 1s
kill -INT $!
The problem is that the process "sox" still runs after my script
executes and the output file is corrupt. Any help on this would be
appreciated.
Are you sure SIGINT is handled correctly by 'rec' ?
Can you kill it by issuing the command at the command line?
Look if it is a matter of the 'rec' or may be a wrong PID in $!
Heinz
(manually wait 1 sec)
<CTRL-C>
That works like I want, and I am just trying to script that.
$! seems to be the correct PID.
I thought SIGINT was supposed to be the same as <CTRL-C>. I think,
based on what I am seing here, it may not be......


change your kill line to

kill -INT 0

this will deliver int to all processes in the process group (your script).
Add comment
Sun Administrator 18 September 2007 16:53:47 permanent link ]
 Is there any command in shell which I can run from command line which
will give me line number in a particular file. e.g.

In /var/adm/messages, I have these two lines -

Sep 7 11:00:34 myhost1 scsi: [ID 107833 kern.notice] ASC: 0x44
(internal target failure), ASC Q: 0x0, FRU: 0x0
Sep 7 12:30:01 myhost1 root: [ID 702911 local0.error] CRITICAL_ISSUE:
Disk error(s) detected on pdxfrc1 - Please verify!

I would like to see if there is a command I can run which gives me the
line number for each of the above line. Another option would be to
compare the date/time of above two lines but not sure how can that be
done easily.

I am a writing another script which would read this messages file and
will send out an alert if CRITICAL_ISSUE line is before "ASC" line.

Thank you for your help.

Add comment
Thomas Glanzmann 18 September 2007 17:08:54 permanent link ]
 Hello,

Is there any command in shell which I can run from command line which
will give me line number in a particular file. e.g.

man nl or my personal favourite:

perl -e 'while(<>) { print "$. $_" }' /var/adm/messages | grep "the line I am interested"

I like the second better, but don't tell anyone.

Thomas
Add comment
Huge 18 September 2007 17:55:04 permanent link ]
 On 2007-09-18, Sun Administrator <sunadm10@yahoo.com­> wrote:
Is there any command in shell which I can run from command line which
will give me line number in a particular file. e.g.

man nl



--
"Religion poisons everything."
[email me at huge {at} huge (dot) org <dot> uk]
Add comment
Guest 18 September 2007 18:00:36 permanent link ]
 On 18 Sep, 15:08, Thomas Glanzmann <sithg...@stud.uni-­erlangen.de>
wrote:
Hello,
Is there any command in shell which I can run from command line which
will give me line number in a particular file. e.g.
man nl or my personal favourite:
perl -e 'while(<>) { print "$. $_" }' /var/adm/messages | grep "the line I am interested"
I like the second better, but don't tell anyone.
Thomas

Why not

grep -n "the line you're interested in" /var/adm/messages

?

Add comment
Oscar del Rio 18 September 2007 18:07:11 permanent link ]
 Thomas Glanzmann wrote:
Hello,
Is there any command in shell which I can run from command line which
will give me line number in a particular file. e.g.
man nl or my personal favourite:
perl -e 'while(<>) { print "$. $_" }' /var/adm/messages | grep "the line I am interested"

or

grep -n "the line I am interested" /var/adm/messages

if you don't mind the ':' after the line number
Add comment
Henry Townsend 18 September 2007 19:33:15 permanent link ]
 cat -n
Add comment
Giorgos Keramidas 18 September 2007 22:14:42 permanent link ]
 On Tue, 18 Sep 2007 06:53:47 -0700, Sun Administrator <sunadm10@yahoo.com­> wrote:
Is there any command in shell which I can run from command line which
will give me line number in a particular file. e.g.
In /var/adm/messages, I have these two lines -
Sep 7 11:00:34 myhost1 scsi: [ID 107833 kern.notice] ASC: 0x44
(internal target failure), ASC Q: 0x0, FRU: 0x0
Sep 7 12:30:01 myhost1 root: [ID 702911 local0.error] CRITICAL_ISSUE:
Disk error(s) detected on pdxfrc1 - Please verify!
I would like to see if there is a command I can run which gives me the
line number for each of the above line.

This should be easy:

cat -n file | grep 'text'

:)­
Add comment
Giorgos Keramidas 18 September 2007 22:16:01 permanent link ]
 On 18 Sep 2007 14:08:54 GMT, Thomas Glanzmann <sithglan@stud.uni-­erlangen.de> wrote:
Is there any command in shell which I can run from command line which
will give me line number in a particular file. e.g.
man nl or my personal favourite:
perl -e 'while(<>) { print "$. $_" }' /var/adm/messages | \
grep "the line I am interested"
I like the second better, but don't tell anyone.

That's odd. Why would you prefer to fire up the Perl interpreter, which
is a fairly sized "beast" when compared with nl(1) or cat(1)? :-)­

Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


RYXI > Linux > Shell Script Question 18 September 2007 22:16:01

see also:
Max tansforming jpegs
[Update] System Information for Windows…
пройди тесты:
see also:
music transfer
Canon Pixma IP1500 how to replace waste…

  Copyright © 2001—2008 RYXI
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.ryxi.com.
Сообщения об ошибках оставляем в сообществе bugs.ryxi.com.
Предложения и комментарии пишем в сообществе suggest.ryxi.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .