Re: c programs & shell conditionals



In article <fnvdte$se2$1@xxxxxxxxxxxxxxxxx>, Hul Tytus <ht@xxxxxxxxx> wrote:
comp.lang.c

How is a unix shell script made to respond to the value returned
by a program compiled from c code?
The shell script below is my current effort, which doesn't work.
The c code shows what was used to generate a.out, seen in the shell script.
The value returned was varied from 0 to 1 for testing.

[re-ordered]

--- c program
int main(int argc, char **argv)
{
return 1; /* or return 0 or exit(0) or exit(1) */
}

Nothing wrong here, except that EXIT_FAILURE is probably better than 1
(though there's a good chance that the value of EXIT_FAILURE is in fact
1 on your platform).


---- shell script
# if [ `/net/u/12/b/br/unet/a.out` > 0 ]
if [ `/net/u/12/b/br/unet/a.out` > /dev/null ]

The people in comp.unix.shell will probably tell you that this line is
wrong.


dave

--
Dave Vandervies dj3vande at eskimo dot com

Their failure is not your excuse; time to find an unaverage pub.
--Richard Bos in the scary devil monastery
.



Relevant Pages

  • Re: I am learning C: a little problem with a simple source code
    ... be used by the parent process, for instance a shell script to detect ... success or failure. ... one who used to be a spurt ...
    (comp.lang.c)
  • Re: RFC: etcupdate tool in base?
    ... any shell script which is intended to be used more than twice ... requires many odd workarounds. ... generate diff output for 'etcupdate diff' so you can generate a patch of your ... difference which is not a failure, but sh -e treats as a failure. ...
    (freebsd-current)
  • Best Way to Check Success/Failure
    ... Is there a more effective way to check the success or failure of an ... action in a shell script? ... I've been using the negation of "if" e.g. ...
    (comp.unix.shell)
  • Re: CFO: Why ./configure?
    ... Isn't it possible to write a shell script, ... AFAIK "make" also can include files, so that platform specific settings only ... are substituted in the created Makefile by e.g. ... software packages. ...
    (comp.os.linux.development.apps)
  • Re: Change the order start up applications
    ... Would a shell script still be the way. ... "Dave Patrick" wrote: ... > Dave Patrick ....Please no email replies - reply in newsgroup. ...
    (microsoft.public.windowsxp.perform_maintain)