Find the answer to your Linux question:
Results 1 to 5 of 5
Hi... I am running damnsmall linux installed to hard disk as debian and have installed sox and cron I am in need of a bash script that will use the ...
  1. #1
    Just Joined!
    Join Date
    Feb 2007
    Posts
    97

    help...I need a bash script

    Hi...
    I am running damnsmall linux installed to hard disk as debian and have installed sox and cron


    I am in need of a bash script that will use the play command to play a wav file repeatedly until I strike a key. and preferable opens a window with a message.
    The key strike thus ending the script- closeing both the window and ending the repeating sound.
    I can have cron run it at the required time. I created a simple script to play a file and made it executable. and cron will run it
    ei:
    #!/bin/bash
    play /path/file.wav

    but do not know how to add a repeat and popup message window,then end with key stroke.

    this could take years based on current reads and progress
    .....Thanks for any help

  2. #2
    Just Joined!
    Join Date
    Jan 2007
    Location
    Germany
    Posts
    73
    Hello,

    the simplest way to raise the window is to use "xmessage" (see the man pages for more details), but there is not so much freedom with formatting styles.

    to play the sound untill the key is pressed, run it in background :

    playSound MyFile.wav &

    printf "press any char" ;
    read char ;
    // Or alternatively xmessage "Press Ok to contunue";

    Hope this gives a clue

  3. #3
    Just Joined!
    Join Date
    Feb 2007
    Posts
    97
    Well..thanks..if there is a clue I am to stupid to see it

    I have dozens of man pages and yes if you type xmessage under the play file.wav then it plays the file and pops up the box

    but I was wanting to attach a stop command to the exit button so when it closes the box it also closes the repeating sound. I guessed a variable was required something like
    function=play$1
    $1=/path/ file.wav
    input=xmessagebox button
    read input
    if input=false;then $1 indefinately
    if input=true;then exit

    this is what I understand so far but it is not a script.
    I thought someone may have done this already and would share the script

    as you can see trial and error are getting nowhere fast

  4. #4
    Just Joined!
    Join Date
    Jan 2007
    Location
    Germany
    Posts
    73
    Have a look at the end of this file

    It starts some command in background (chess program KNights), then asks if you want to finish. If yes, it "commits suicide" -kills itself and its child (KNights program)

    Substitute "KNights" with your "play sound.wav"

    Hope this helps you.
    ------------------------------------------------------
    Code:
    #!/bin/bash
    
    #Add some formatting stuff not to repeat it several times
    XMESSAGE="/usr/X11R6/bin/xmessage  -fn  -adobe-times-bold-i-normal--24-240-75-75-p-128-iso8859-1 -title Question -center ";
    RunMyProgram="knights";  # KNights is a chess program under KDE. Put your program here
    
    function CommitSuicide() { $XMESSAGE -buttons "Yes: 0, No: 2" " Commit a suicide ???"; Commit_Status=$?; until [ $Commit_Status = "0" ] ;  do $XMESSAGE  -fg red -buttons "Yes: 0, No: 2" " Commit a suicide ??? " ; Commit_Status=$? ; done; if [ $Commit_Status = "0" ]; then $XMESSAGE -timeout 1  -buttons "" " Ok, commitong a suicide ..." && $XMESSAGE -timeout 1  -buttons "" "Killing the child processes in background first ... " && kill $! && kill $$ ;fi; }
    
    $RunMyProgram&
    CommitSuicide;

  5. #5
    Just Joined!
    Join Date
    Feb 2007
    Posts
    97

    Red face

    Thanks..
    seems odd to me..one would think a repeating alarm with an off button would be handy program or script and many would be available...oh well..guess not

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •