OK. This version is fine.
Orvalho On Sun, Feb 3, 2013 at 1:45 PM, Bob Jolliffe <bobjolli...@gmail.com> wrote: > No I don't think so. The reference you give is Advanced Bash Scripting > Guide. > > The problem here is that the script is 100% fine bash script, but not > when you execute with /bin/sh. Which does have different conventions > around function names - and also doesn't seem to understand ERR. The > following is more portable: > > #!/bin/sh > > # get ready to catch keyboard interrupt > trap ctrl_c INT > > ctrl_c () { > echo > echo "============================================" > echo "Keyboard interrupt" > echo "DHIS2 live exited" > echo "============================================" > exit > } > > unexpected_exit () { > echo "============================================" > echo "DHIS2 live exited with an error" > echo "Make sure you have a java runtime in your path" > echo "============================================" > read -p "Press enter to exit" ch > exit > } > > echo "Starting DHIS2 live ..." > > DHIS2LIVE=`dirname $0` > java -jar $DHIS2LIVE/dhis2-live.jar || unexpected_exit > echo "DHIS2 live exited normally" > > > On 3 February 2013 07:20, Orvalho Augusto <orvaq...@gmail.com> wrote: > > There are two problems here: > > > > 1. The syntax to define a function. Can we check > > http://tldp.org/LDP/abs/html/functions.html > > > > 2. The character "-" is really trick when define functions with. > > > > I changed to this: > > #!/bin/bash > > > > # get ready to catch errors > > trap ctrl_c INT > > trap unexpected_exit ERR > > > > ctrl_c () { > > > > echo > > echo "============================================" > > echo "Keyboard interrupt" > > echo "DHIS2 live exited" > > echo "============================================" > > exit > > } > > > > unexpected_exit () { > > > > echo "============================================" > > echo "DHIS2 live exited with an error" > > echo "Make sure you have a java runtime in your path" > > echo "============================================" > > read -p "Press any key to exit" > > } > > ... > > > > That works fine. Yes, it's really strange that only these days this is > > reported! > > > > Caveman > > > > > > > > On Fri, Feb 1, 2013 at 12:01 PM, Neeraj Gupta <neeraj.h...@gmail.com> > wrote: > >> > >> Lars, > >> > >> Below is the content of startup.sh > >> > >> #!/bin/bash > >> > >> # get ready to catch errors > >> trap ctrl-c INT > >> trap unexpected-exit ERR > >> > >> function ctrl-c () { > >> echo > >> echo "============================================" > >> echo "Keyboard interrupt" > >> echo "DHIS2 live exited" > >> echo "============================================" > >> exit > >> } > >> > >> function unexpected-exit () { > >> echo "============================================" > >> echo "DHIS2 live exited with an error" > >> echo "Make sure you have a java runtime in your path" > >> echo "============================================" > >> read -p "Press any key to exit" > >> } > >> > >> echo "Starting DHIS2 live ..." > >> # java -jar dhis2-live.jar > >> DHIS2LIVE=`dirname $0` > >> #$JAVA_HOME/bin/ > >> java -jar $DHIS2LIVE/dhis2-live.jar > >> echo "DHIS2 live exited normally" > >> > >> > >> > >> On Fri, Feb 1, 2013 at 3:14 PM, Lars Helge Ă˜verland < > larshe...@gmail.com> > >> wrote: > >>> > >>> Hi Neeraj, > >>> > >>> can you post the contents of the startup.sh script? > >>> > >>> Lars > >>> > >>> > >>> On Fri, Feb 1, 2013 at 11:26 AM, Neeraj Gupta <neeraj.h...@gmail.com> > >>> wrote: > >>>> > >>>> Hi Devs, > >>>> > >>>> I was trying to work with DHIS Live on Ubuntu Server 11.10 , but I am > >>>> unable to run it, when i am running startup.sh it is saying > >>>> trap: ERR: bad trap > >>>> /home/dhis-live/startup.sh: 7: Syntax error: "(" unexpected > >>>> > >>>> Downloaded it from http://www.dhis2.org/downloads > >>>> > >>>> Tried it on windows and it worked fine. > >>>> Does DHIS-Live work with Linux also or it works with windows only? > >>>> > >>>> > >>>> > >>>> -- > >>>> Thanks, > >>>> Neeraj Gupta > >>>> > >>>> _______________________________________________ > >>>> Mailing list: https://launchpad.net/~dhis2-devs > >>>> Post to : dhis2-devs@lists.launchpad.net > >>>> Unsubscribe : https://launchpad.net/~dhis2-devs > >>>> More help : https://help.launchpad.net/ListHelp > >>>> > >>> > >> > >> > >> > >> -- > >> Thanks, > >> Neeraj Gupta > >> > >> _______________________________________________ > >> Mailing list: https://launchpad.net/~dhis2-devs > >> Post to : dhis2-devs@lists.launchpad.net > >> Unsubscribe : https://launchpad.net/~dhis2-devs > >> More help : https://help.launchpad.net/ListHelp > >> > > > > > > _______________________________________________ > > Mailing list: https://launchpad.net/~dhis2-devs > > Post to : dhis2-devs@lists.launchpad.net > > Unsubscribe : https://launchpad.net/~dhis2-devs > > More help : https://help.launchpad.net/ListHelp > > >
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp