Archived

This forum has been archived. Please start a new discussion on GitHub.

shell script

I wrote the following shell script:

#!/bin/sh

cd dataStreamTransferWithDataBaseSurface
icegridregistry --Ice.Config=config.registry &
cd Server
streamServer --Ice.Config=config.server &
cd ..
cd ..
cd dataBaseSurface
cd asyncControl
dataBaseSurface --Ice.Config=config.client

And i get the error message:
warning: commands will be executed using /bin/sh

How I can start icegridregistry, my server and client with a shell script??

greeting
Peter

Comments

  • shell script

    I changed my previous shell script to this version (filename: batch):

    #!/bin/sh

    cd dataStreamTransferWithDataBaseSurface
    echo "Starting registry ..."
    icegridregistry --Ice.Config=config.registry &
    sleep 2
    echo "done."
    cd Server
    echo "Starting server ..."
    ./streamServer --Ice.Config=config.server &
    sleep 2
    echo "done."
    cd ..
    cd ..
    cd dataBaseSurface
    cd asyncControl
    echo "Starting client ..."
    ./dataBaseSurface --Ice.Config=config.client

    And I can start my shell script with:
    $ bash batch

    And I have the following questions:
    How I can wait, until a process is finisted, without using sleep??
    How in my script I can start the server in a new console??

    greeting

    Peter
  • xdm
    xdm La Coruña, Spain
    Hi,
    warning: commands will be executed using /bin/sh

    This warning only means that commands in the script are executed using /bin/sh shell.
    cd dataStreamTransferWithDataBaseSurface
    icegridregistry --Ice.Config=config.registry &
    cd Server
    streamServer --Ice.Config=config.server &
    cd ..
    cd ..
    cd dataBaseSurface
    cd asyncControl
    dataBaseSurface --Ice.Config=config.client

    If you want to start icegridregistry as a daemon, don't use '&', when this could work is better to pass --daemon to igridregistry.

    I will also avoid all the 'cd' it made the script complex. IMO is better to use absolute paths with in your scripts.

    In a bash compatible shell this should work.

    ICE_HOME="/opt/Ice-3.3"
    ICEGRID=$ICE_HOME"/bin/icegridregistry"

    MYAPP_HOME="/opt/myapp"

    GRID_CONFIG=$MYAPP_HOME"/config/config.grid"


    SERVER_CONFIG=$MYAPP_HOME"/config/config.server"
    SERVER=$MYAPP_HOME"/bin/server"

    CLIENT_CONFIG=$MYAPP_HOME"/config/config.client"
    CLIENT=$MYAPP_HOME"/bin/client"

    #
    # Start icegridnode node.
    #
    $ICEGRID --Ice.Config=$GRID_CONFIG --daemon

    #
    # Start myapp server
    #
    $SERVER --Ice.Config=$SERVER_CONFIG &


    #
    # Start myapp client
    #
    $CLIENT --Ice.Config=$CLIENT_CONFIG

    To start your own server as a daemon is better that you inherit from Ice::Service, and then start the server with --daemon option instead of use '&' in the script.

    If you are using RHEL or SUSE you could be interested in the init.d scripts that are provided to start ice services:

    /etc/init.d/glacier2router
    /etc/init.d/icegridnode
    /etc/init.d/icegridregistry

    Cheers,
    José
  • bernard
    bernard Jupiter, FL
    Hi Peter,

    I don't know why you get this warning: it's not Ice-related. A work-around could be to use !/bin/bash for our shell script.

    I would also suggest to use --daemon to start the IceGrid registry, instead of putting it background. This way, the IceGrid registry will fork itself and wait until it's started to return and let the script continue. You could also do the same for your streamServer server: see 8.3.2 The Ice::Service Class in the Ice manual (http://www.zeroc.com/doc/Ice-3.3.1/manual/Cpps.9.3.html).

    Best regards,
    Bernard