| Server IP : 52.9.100.119 / Your IP : 216.73.217.7 Web Server : Apache/2.4.61 (Amazon) OpenSSL/1.0.2k-fips PHP/7.3.30 Phusion_Passenger/5.1.5 System : Linux ip-172-31-9-35 4.14.355-196.618.amzn1.x86_64 #1 SMP Mon Apr 7 17:09:50 UTC 2025 x86_64 User : root ( 0) PHP Version : 7.3.30 Disable Function : exec,passthru,shell_exec,system,popen,proc_open MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /usr/bin/ |
Upload File : |
#!/bin/sh
#
# faxq program
#
# like "lpq" or "mailq", show jobs waiting in the output queue
#
# SCCS: $Id: faxq.in,v 4.11 2005/04/16 11:29:09 gert Exp $ Copyright (C) 1994 Gert Doering
#
FAX_SPOOL=/var/spool/fax
FAX_SPOOL_OUT=/var/spool/fax/outgoing
#
# echo program that will accept escapes (bash: "echo -e", sun: /usr/5bin/echo)
#
echo="echo -e"
#
# an awk that is not stone-old-brain-dead (that is, not oawk...)
#
AWK=awk
#
# helper program for privileged queue access
FAXQ_HELPER=/usr/lib64/mgetty+sendfax/faxq-helper
# ------------- subroutines -----------
do_faxq_stop()
{
if [ ! -w . ]
then
$echo "$0: not administrator, can't stop queue" >&1 ; exit 0
fi
id >stop
}
do_faxq_start()
{
if [ ! -w . ]
then
$echo "$0: not administrator, can't start queue" >&1 ; exit 0
fi
if [ ! -f stop ]
then
$echo "$0: queue not stopped, can't restart" >&1 ; exit 0;
fi
rm -f stop
}
# -------------------------------------
if cd $FAX_SPOOL_OUT
then :
else
$echo "cannot chdir to $FAX_SPOOL_OUT..." >&2
exit 1
fi
# special commands: faxq stop / start
case $1 in
stop) do_faxq_stop ; exit 0;;
start) do_faxq_start ; exit 0;;
'') ;;
-*) ;;
*) cat <<EOF_MSG >&2
$0: invalid command: $1
valid commands:
stop stop fax queue handling (admin only)
start restart stopped fax queue (admin only)
EOF_MSG
exit 1 ;;
esac
jobs="*/JOB"
requeue=""
changepri=""
while [ -n "$1" ]
do
case $1 in
-v) verbose="true" ;;
-o) jobs="*/JOB.done" ;;
-s) jobs="*/JOB.s*" ;;
-a) jobs="*/JOB*" ;;
-r) jobs="*/JOB.s*"; requeue="true" ;;
-P) if [ -z "$2" -o -z "$3" ] ; then
echo "$0: -P needs arguments!" >&2 ; exit 1 ;
fi
jobs="$2/JOB"; changepri="$3" ; shift ; shift
;;
*) cat <<EOF_MSG >&2
$0: invalid option: $flag
valid options:
-o: show old jobs
-s: show suspended jobs
-a: show all jobs
-v: verbose output
-r: restart suspended jobs
-P <job> <pri>: change priority of job <job> to <pri>
EOF_MSG
exit 1 ;;
esac
shift
done
jobs=`ls $jobs 2>/dev/null`
[ -z "$jobs" ] && $echo "no jobs."
for i in $jobs
do
USER=""; PHONE=""; PAGES=""; MAILTO=""; VERBTO="";
ACCT=""; INPUT=""; TIME=""; PRI=""; RE=""
# read jobs using 'tr', remove all quote characters, dollar, and backslash
if [ -z "$verbose" ]
then
eval `tr -d '\042\047\140\134\044\073' <$i | \
$AWK '$1=="user" { printf "USER=%s;", $2 }
$1=="phone" { printf "PHONE=%s;", $2 }
$1=="pages" { printf "PAGES=%d;", NF-1 }
$1=="priority" { printf "PRI=\" pri=%s.\";", $2}' -`
$echo "$i: queued by $USER. $PAGES page(s) to $PHONE.$PRI"
else
eval `tr -d '\042\047\140\134\044\073' <$i | \
$AWK '$1=="user" { printf "USER=%s;", $2 }
$1=="mail" { printf "MAILTO=\"%s\";", substr( $0, 6 ) }
$1=="phone" { printf "PHONE=%s;", $2 }
$1=="verbose_to" \
{ printf "VERBTO=\"%s\";", substr( $0, 12 ) }
$1=="acct_handle" \
{ printf "ACCT=\"%s\";", substr( $0, 13 ) }
$1=="input" { printf "INPUT=\"%s\";", substr( $0, 7 ) }
$1=="time" { printf "TIME=\"%s:%s\";",
substr( $0, 6, 2 ), substr( $0, 8,2 ) }
$1=="subject"{ printf "RE=\"%s\";", substr( $0, 9 ) }
$1=="priority"{ printf "PRI=\"%s\";", $2 }
$1=="pages" { if ( NF==2 ) printf "PAGES=\"%s\";", $2
else if ( NF==3 )
printf "PAGES=\"%s %s\";", $2, $3
else
printf "PAGES=\"%s ... %s\";", $2, $NF
}' -`
$echo "$i:"
$echo "\tQueued by: $USER"
if [ -z "$VERBTO" ]
then
$echo "\t to: $PHONE"
else
$echo "\t to: $VERBTO ($PHONE)"
fi
test ! -z "$RE" && \
$echo "\t Re: $RE"
test ! -z "$MAILTO" && \
$echo "\t E-Mail: $MAILTO"
test ! -z "$INPUT" && \
$echo "\t Input: $INPUT"
$echo "\t Pages: $PAGES"
test ! -z "$TIME" && \
$echo "\tSend time: $TIME"
test ! -z "$ACCT" && \
$echo "\tAcct info: $ACCT"
test ! -z "$PRI" && \
$echo "\t Priority: $PRI"
sed -e '/Status/!d' -e 's/Status/ Status:/' $i
if [ -f "$i.locked" ] ; then
$echo "\t Status: LOCKED (being sent right now)"
else
expr $i : ".*done$" >/dev/null ||
$echo "\t Status: not sent yet"
fi
fi
# if "changepri", change priority of job
# TODO - this is currently broken, needs changing over to $FAXQ_HELPER
if [ -n "$changepri" ] && expr "$i" : ".*JOB$" >/dev/null
then
d=`dirname $i`
if [ ! -w $d ] ; then
$echo "$i: not owner, can't change priority"
else
echo "priority $changepri" >>$i
$echo "Priority changed to $changepri"
touch .queue-changed 2>/dev/null
fi
fi
# if "requeue", requeue *.suspended-Jobs
if [ -n "$requeue" ] && expr "$i" : ".*JOB.s" >/dev/null
then
d=`dirname $i`
$FAXQ_HELPER requeue $d
fi
done
test -n "$verbose" -a -n "$jobs" -a -r faxqueue_done &&
$echo "\nLast \`\`faxrunq'' run at: `cat faxqueue_done`"
# queue stopped? (print only if not "no jobs.")
test -n "$jobs" -a -f stop &&
$echo "\nWarning: fax queue handling stopped (stop file exists).\n"