[Gambas-user] need help Script to start program

Mike Keehan mike_keehan at ...679...
Thu Nov 11 21:20:49 CET 2004


Ron Onstenk wrote:
> [off-gambas]
> 
> I have a simple problem
> 
> I have made a script but I'm doing something wrong.
> I know RTFM but which and where to search for, I've bad luck
> with bash scripts every time, sorry
> 
>  
> #!/bin/sh
> # i want to run next line
> # timidity.sh /data3/media/audio/midi/gus2/SOFUNKY.MID
> # it has to kill running instance(s) before new one start 
> # it needs a audio output and is blocked if not killed.
> #
> # The script is a stub between the *.mid file assoc and the
> # program to use it as argument.
> 
> # how to get safe the PID to kill ???
> #TIMID=`ps -ax |grep timidity`
> #echo "proc=${RUN}"
> TIMID=timidity
> 
> NFIL=$1 # the argument from the command
> NFIL=/data3/media/audio/midi/gus2/SOFUNKY.MID
> 
> # get the running file 
> OFIL=`cat /var/tim.lock`
> 
> #kill running timidity
> kill -TERM ${TIMID} #here it can't find ???
> 
> if [ -f /var/tim.lock ] ; then
>   echo "exit player for ${OFIL}"
>   unlink /var/tim.lock
> fi
> 
> echo ${NFIL} > /var/tim.lock
> echo "playing now ${NFIL}"
> 
> # run program with new argument
> # should it exit or stay running
> # till process is done?
> timidity ${NFIL} & # <-- do I need the & at the end?
> 
> [/offgambas]
> 
> I assume it is not difficult but as told, I have bad luck.
> I want to play midi files and it should not block until ready.
> If I select an other midi file it must abort the playing one 
> and start to play the new selected one.
> 
> Ron
> 
> 

You could try this:-

     killall -TERM timidity

Also, at a terminal/console prompt,    man -k kill   will show you all 
commands related to kill.  (man -k needs the 'makewhatis' command to 
be run daily or whenever new software is installed).

As for the '&', it is probably easiest to try it and see.  If you want 
the script to end but leave timidity running in the background, then 
add the '&' character.  Note that some programs will automatically go 
into the background on their own - I don't know if timidity does or not.

Mike.





More information about the User mailing list