Re: Viewing multiple .png files simultaneously



On 2007-09-19, philbo30 wrote:
On Sep 19, 10:19 am, "Chris F.A. Johnson" <cfajohn...@xxxxxxxxx>
wrote:
On 2007-09-19, Josef Moellers wrote:
Chris F.A. Johnson wrote:
On 2007-09-19, philbo30 wrote:
...

ImageMagick is just the tool I was looking for; it works great. The
only additional thing I would like to do is specify the amount of time
that the image displays. As an example, I want it to display for 60
seconds. I didn't see that capability associated with the "display"
application, but then again I didn't look that much either. Ideas?

display ... &
sleep 5
kill "$!"

<pedantic>
make that
display ... &
sleep 60
kill $!
</pedantic>

What if IFS is not the default? E.g.:

$ (> IFS=1234567890
sleep 20 &
sleep 2
kill $!
)

bash: kill: `': not a pid or valid job spec
bash: kill: `': not a pid or valid job spec
bash: kill: `': not a pid or valid job spec
bash: kill: `': not a pid or valid job spec
$

But:

$ (> IFS=1234567890
sleep 20 &
sleep 2
kill $!
)

$

In this case the quotes are needed; in other cases it doesn't hurt
to have them.

So here's what I have currently using a Linux system() call in a C
app:

system("display array.png &");
system("sleep 5");
system("kill $!");

Each system() call starts a new shell, so there is no background
command to have generated $!.

system("display array.png & sleep 5; kill $!" );

Clearly there is a problem with my kill syntax since the display never
ends until I manually kill it, at which time I see:

"kill: usage: kill [-s sigspec | -n ...........]"

It seems like I need something like this:

system("kill "$!""); //clearly doesn't work

So, last question, what is the syntax for quotes within quotes? I am
on GNU bash version 2.05a.0(1) i686-pc-linux-gnu [Red Hat 7.3, gcc
2.96]

Escape the quotes (in C or bash):

system("kill \"$!\"");

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
.



Relevant Pages

  • Re: [RFC] page fault retry with NOPAGE_RETRY
    ... Suppose a program (let's call it "DoS") is written which sits in a loop ... bash will take a major fault, will submit a read and then it will do ... Particularly since every other program in the machine is stuck in disk wait ... having to kill off sshd, xinetd, httpd, etc isn't a very happy solution. ...
    (Linux-Kernel)
  • Re: Viewing multiple .png files simultaneously
    ... kill "$!" ... bash: kill: `': not a pid or valid job spec ...
    (comp.os.linux.development.apps)
  • Re: [SLE] basic shell signal question
    ... > shell script? ... Send the processes named by PID the signal SIGSPEC. ... Kill is a shell ... Naturally, "man bash" would tell you this, as well. ...
    (SuSE)
  • Re: tty session leader issue (was Re: 2.6.25.3: su gets stuck for root)
    ... during the initialization of a new bash shell, ... All of my machines exhibit the ctrl-C being slower than ctrl-Z discussed ... elswhere (I've almost developed a habit of typing ctrl-Z kill %1 ). ... if this is the cause of dpkg recently not responding to ctrl-Z's? ...
    (Linux-Kernel)
  • Re: =?iso-8859-1?Q?variable=3DStrart=5FProgramPID =3F=3F?=
    ... > I wrote a bash script from which I call one c-program, that is mainly a loop. ... > But in the script I would like to be able to just kill the loop. ...
    (Debian-User)