HylaFAX The world's
most advanced open source fax server
|
|
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
[hylafax-users] help needed debugging bash script
I'm working on a bug in a HylaFAX bash script which appears in all tested
versions of bash-2.0x. I need some help; so if you're a bash junkie, I'd
appreciate a pointer.
The problem surfaces in the faxaddmodem script, when this text appears
unexpectedly while the modem is probed for its class capabilities:
[1]+ Terminated ( trap 0 1 2 15; while true; do
sleep 10; echo ""; echo "Hmm, something seems to be hung, check your
modem e
h?";
done )
What is this? This is the shell printing the exit status of an
asynchronous process. This doesn't happen in bash-1.14, and for aesthetic
purposes, we don't want this showing up in the middle of faxaddmodem or any
other HylaFAX bash script.
So, my question is, how do we get rid of that? You can use this test
script for an example:
#! /bin/bash
( yes >&- )&
nagpid=$!
ps -e | grep $nagpid
kill -15 $nagpid
sleep 1
ps -e | grep $nagpid
Under bash-2.0x you'll get something like this:
8049 pts/0 00:00:00 testme
./testme: line 6: 8049 Terminated ( yes 1>&- )
What we want is this output (as in bash-1.14):
8049 pts/0 00:00:00 testme
I've tried redirecting the kill output via, 'kill -15 $nagpid >/dev/null
2>&1', but that doesn't work (as it shouldn't, since it's the shell giving
the message). I've tried turning monitor mode (job control) off via, 'set
+m'. That didn't work, either. I've also tried the builtin kill versus
the external kill, and both give the same results. I've tried executing it
as /bin/sh rather than /bin/bash, and that changed nothing.
There were numerous changes to job control and signal processing between
bash versions 1.14 and 2.04, as documented in the CHANGES doc file, but
nothing seems to stick out to me as particularly relevant. Although, I do
see:
v. A fix was made to the job control code so that the shell behaves better
when monitor mode is enabled in a non-interactive shell.
If anyone could help with this, I surely would appreciate it. Following is
the actual script from faxaddmodem, if you're interested.
Thanks.
Lee Howard
RESULT="";
while [ -z "$RESULT" ]; do
#
# This goes in the background while we try to
# reset the modem. If something goes wrong, it'll
# nag the user to check on the problem.
#
(trap 0 1 2 15;
while true; do
sleep 10;
echo ""
echo "Hmm, something seems to be hung, check your modem eh?"
done)& nagpid=$!
trap "$RMCMD \$JUNK; $RMCMD -r $TMPDIR; kill $nagpid \$catpid; exit 1"
0 1 $
SendToModem "AT+FCLASS=?" # ask for class support
kill $nagpid
trap "$RMCMD \$JUNK; $RMCMD -r $TMPDIR; test \"\$catpid\" && kill
\$catpid;$
sleep 1
RESULT=`tr -ds '\015' '\012' < $OUT | tail -1`
if [ -z "$RESPONSE" ]; then
echo ""
echo "There was no response from the modem. Perhaps the modem is"
echo "turned off or the cable between the modem and host is not"
echo "connected. Please check the modem and hit a carriage return"
prompt "when you are ready to try again:"
read x
fi
done
____________________ HylaFAX(tm) Users Mailing List _______________________
To unsub: mail -s unsubscribe hylafax-users-request@hylafax.org < /dev/null