On Thu, Nov 20, 2003 at 10:49:45AM -0500, Matt Price wrote:
> is it possible in bash to test whether a comand has actually worked?
> I feel like I've seen such tests, but I tried one and can't make it
> work for me: 
> 
> #! /bin/bash
> if [ 'gnuclient -q $*' ]; then 

That's definitely wrong: 'gnuclient -q $*' is just a string, not "call
this program". Also, there's no need to use [ ] (a.k.a. /usr/bin/test)
for this purpose. Just check the program's exit status directly:

  if gnuclient -q $*; then
    # success
  else
    # failure
  fi

Alternatively, you can look at $? for the command's exit status.

Cheers,

-- 
Colin Watson                                  [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to