Find the answer to your Linux question:
Results 1 to 3 of 3
Hi I am having a sh file which in turn has calls to many other sh files and all the calls are followed by an echo to check the control ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    2

    Post problem with the echo command

    Hi

    I am having a sh file which in turn has calls to many other sh files and all the calls are followed by an echo to check the control flow.The problem is that even if an exception occurs in any of the script file execution , the original script file(the caller script ) continues execution.

    Example

    Line 1 : Echo "executing script A.sh for stopping process1"
    line 2: $<path>/A.sh

    Line 3: Echo "Executing script B.sh to stop process 2"
    Line 4: $<path>/A.sh
    line 5: Echo "Script execution succcessfull"


    So in this case if an error occurs in line 4, then would line 5 still go and print that script executed sucessfully.

    So cant i make sure that if any of the scripts that i called inside this script failed then i should not continue executing the parent script, should i go for exclusive conditions checks to ascertain the same.

  2. #2
    Just Joined!
    Join Date
    Aug 2007
    Posts
    5
    Hi Raj,

    try to put the child script runs in some conditions, fe :

    if /tmp/a.sh ;then
    echo "ok"
    else
    echo "a failed "
    exit 1
    fi

    then you can put exit in the condition if you want also the master process script to end or any other action.

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Posts
    2

    Smile Usage of nohup in an if condition

    Hi

    I have to use nohup along with the sh script.
    How can i use if condition also in this.

    The original line is script is
    nohup $Start_NODEM > $Start_NODEM.out &

    where Start_NODEM =$INSTALL_DIR/A.sh

    have to make it similar to the one below:

    if /tmp/a.sh ;then
    echo "ok"
    else
    echo "a failed "
    exit 1
    fi


    Thanks
    Praveen

Posting Permissions

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