Re: Waiting on end of program execution from shell script?
From: Alan Connor (zzzzzz_at_xxx.yyy)
Date: 02/16/05
- Previous message: Ted Timar: "Unix - Frequently Asked Questions (6/7) [Frequent posting]"
- In reply to: Barry Margolin: "Re: Waiting on end of program execution from shell script?"
- Next in thread: Alan Connor: "Re: Waiting on end of program execution from shell script?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 16 Feb 2005 07:21:54 GMT
On Wed, 16 Feb 2005 00:09:46 -0500, Barry Margolin
<barmar@alum.mit.edu> wrote:
> In article <GExQd.1338$IU.64@newsread3.news.pas.earthlink.net>,
> Alan Connor <zzzzzz@xxx.yyy> wrote:
>
>> On Wed, 16 Feb 2005 01:41:06 +0100, Matthias Zach
>> <zach228@fortuencity.com> wrote:
>>
>>
>> > From a shell script I want to execute a java program (e.g.
>> > myprog.class) among other commands.
>> >
>> > How do specify the program call statement in this script
>> > that:
>> >
>> > 1.) the further shell script execution should wait until the
>> > java program finishes
>>
>> Assuming bash. (you should have specified what shell you are
>> using)
>>
>> myprog.class &&
>
> Why do you need '&&'? The normal behavior of virtually all
> shells is to wait for a command to finish before executing the
> next command. No special syntax is needed.
>
That's what I was taught to use by the other pros on
comp.unix.*, when one wants to make sure that the previous
command has completely finished before the next one was executed.
But you have inspired me to take a look at man bash, and it turns
out that '&&' is the logical AND operator and only executes the
second command if the first one exits with an exit code of zero.
Which is a bit of a different thing and could definitely cause
problems with the script that the OP is apparently trying to
write, where he may be checking for other exit codes from the
first program.
For the OP: The '||' operator will execute the second
command only if the first one exits with a non-zero exit code.
Good call, Barry.
Thanks.
AC
- Previous message: Ted Timar: "Unix - Frequently Asked Questions (6/7) [Frequent posting]"
- In reply to: Barry Margolin: "Re: Waiting on end of program execution from shell script?"
- Next in thread: Alan Connor: "Re: Waiting on end of program execution from shell script?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|