HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [hylafax-users] Having problems running sendfax from a bash script.



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lee Howard schrieb:

>> I'd like to check the error code that sendfax returns, I assume it
>> returns one, so I can return a error if the sendfax failed. So far
>> I've not been able to get the return code. Can some one point me in
>> the right direction?

Hello John,

what exactly is your problem?
1. How to check the exit code in a shell (bash) script?
2. A list of possible exit codes?

> sendfax does not provide a meaningful exit code.

On my system it does provide exit code 0 on success and 255 on some errors, probably on any error during submission of the fax job. (That answers question 2)
I tried these errors: no arguments at all, missing destination option, file not found or not accessible, empty file, no connection to server.

So it seems possible to tell if the submission of the job was successful. But you cannot distinguish between different types of errors. You probably have to capture stderr of the sendfax command and write this to a logfile or show it to the user. (It would be possible to change sendfax to use more specific exit codes on submission errors.)

And now some example code for question 1:

if sendfax -d $DESTINATION $FILE > sendfax.out 2> sendfax.err
then
   REQUEST=`sed -e 's/request id is //' -e 's/ .*//' sendfax.out`
   echo fax job $REQUEST successfully submitted
else
   ERRMSG=`cat sendfax.err`
   echo submission of fax job failed, error message: $ERRMSG
fi


Or with the code example you wrote on 16.06.2007 it can be something like this:

commandline="eval sendfax $commandparms"

if $commandline
then
   ...
else
   ...
fi


I wrote the example code without actually trying it, so it may contain bugs.

> If you want to check
> the status of a submitted fax you have to refer to the doneq (or sendq)
> file (thus, use faxstat).

As Lee already explained, it is impossible to get any information about the progress of a _submitted_ fax. That means you have to use faxstat to get further information if sendfax has returned exit code 0.


Bodo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGiM9EnMz9fgzDSqcRAox7AJ9bwSbu3AInDsbUasXUX/csrn3y8QCcDqga
lcSA2rH1linEJaxHYx0v7Eg=
=I8Ov
-----END PGP SIGNATURE-----

____________________ HylaFAX(tm) Users Mailing List _______________________
  To subscribe/unsubscribe, click http://lists.hylafax.org/cgi-bin/lsg2.cgi
 On UNIX: mail -s unsubscribe hylafax-users-request@xxxxxxxxxxx < /dev/null
  *To learn about commercial HylaFAX(tm) support, mail sales@xxxxxxxxx*




Project hosted by iFAX Solutions