UPDATE: 3/12/2010 : bytesolutions
FreePBX includes a setup for faxing; however, two components needed for operation are not installed.
FreePBX includes a setup for faxing; however, two components needed for operation are not installed.
Additional info: http://www.voip-info.org/wiki/view/app_rxfax+and+app_txfax
·                  SpanDsp: http://soft-switch.org/
·                  AGX Extra Add-ons for Asterisk – consisting of modules for rxfax and txfax functions.
·           Due to Asterisk project dual license some useful code cannot be submitted into the official repository.
This includes:
·             enhanced app_rxfax (app_rxfax)
·             enhanced app_txfax (app_txfax)
·             device state (DevState from Bristuff)
·             Pickup2 (enhanched Pickup, taken from Bristuff)
·             FAX Background detect (nv_background_detect)
·             FAX detect (nv_faxdetect)
No patching is required, the source use the same structure as the official add-ons using an independent build system with a nice XML menu tree selection tool. Note that for fully working FAX support you will need at least spanDSP 0.0.4 pre16.
SpanDSP should be installed first. A specific version is suggested 0.0.4 pre16.
-
Make sure the other requisites are installed.
-
Install CMake
-
http://atrpms.net/dist/el5/cmake/
-
-
./configure
-
make
-
make install
AGX Extra Add-ons for Asterisk
- You can find the source via tarball or svn at https://sourceforge.net/projects/agx-ast-addons/
- Use svn to get the latest files.
- svn co https://agx-ast-addons.svn.sourceforge.net/svnroot/agx-ast-addons agx-ast-addons
- Traverse to the trunk folder.
- Read the README for additional details.
- You will need to add the lib path to the config and run ldconfig or the setup will fail.
fax2mail – This may be a useful script for emailing the fax as a pdf.
 #!/bin/bash
#=========================================================================|
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
# File: fax2mail                                                         |
# Type: BASH script                                                      |
# Summary: fax to E-Mail helper application for asterisk PBXÂ Â Â Â Â Â Â Â Â Â Â Â Â |
# Description: fax2mail is a helper application which sits between       |
#  asterisk and a MTA. Is is designed to be called by asterisk upon the |
#  receipt of a new fax. It will forward the received fax to the email |
#  address of choice, and will convert the file the one of several      |
#  formats.                                                             |
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#=========================================================================|
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
# Usage:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â fax2mail allows these parameters from asterisk as follows:Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â Â -p = To attach in pdf format (default)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#    -e = To attach in eps format                                       |
#    -t = To attach in tif format                                       |
#    -f = absolute path to file w/out .tif extension                    |
#Â Â Â Â –cid-name <CID Name> = Set CID Name of caller to <CID Name>Â Â Â Â Â Â Â |
#Â Â Â Â –cid-number <CID Number> = Set CID Number of caller to <CID Number>|
#    –dest-exten <Exten Called> = Used to look up destination info     |
#        from voicemail.conf.                                           |
#    –dest-email <Destination Email> = Used to send teh email to.      |
#        optional if –dest-exten is provided so that the email address |
#        can be looked up in voicemail.conf                             |
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#=========================================================================|
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
# Examples:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#  fax2mail -f /absolute/path/file                                      |
#    file.tif in /absolute/path/ would be coverted to a pdf and sent to |
#    the email address specified in the ‘DEFAULTTO’ global variable     |
#Â Â fax2mail -f /absolute/path/file –dest-exten 100Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â Â file.tif in /absolute/path/ would be converted to a pdf and sent to |
#    the email address associated with the exten 100 in voicemail.conf  |
#Â Â fax2mail -t -f /absolute/path/file –dest-email [email protected]Â Â Â Â Â Â |
#    file.tif in /absolute/path/ would be emailed in tif format to      |
#Â Â Â Â [email protected]Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#=========================================================================|
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Astrerisk config:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â [default]Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â …Unimportant stuff removed for this…Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#   ;Detected fax call                                                  |
#Â Â Â exten => fax,1,Goto(fax,s,1)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â [fax]Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â exten => s,1,Macro(recvfax)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â exten => h,1,System(‘/usr/bin/fax2mail –cid-number ‘${CALLERIDNUM}’ |
#Â Â Â Â Â Â Â Â Â Â Â Â –cid-name ‘${CALLERIDNAME}’ –dest-exten ‘${INIT_EXTEN}’Â Â |
#Â Â Â Â Â Â Â Â Â Â Â Â -f ‘${FAXFILE}”)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â NOTE: INIT_EXTEN has to be set with something similar to…Â Â Â Â Â Â Â Â Â |
#Â Â Â Â Â Â Â Â Â exten => s,n,Set(INIT_EXTEN=${EXTEN})Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â [macro-recvfax]Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â ;Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â ;Â Receive incoming fax macro:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â ;Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â exten => s,1,Set(FAXFILE=/var/spool/asterisk/fax/${STRFTIME(${EPOCH} |
#Â Â Â Â Â Â Â Â Â Â Â Â Â ,,%Y%m%M%S)}-${CALLERIDNUM}-${INIT_EXTEN})Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â exten => s,2,rxfax(${FAXFILE}.tif)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#=========================================================================|
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
# Dependencies:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#  This application requires asterisk, ast_fax, app_rxfax, tifflib      |
#  mime-construct                                                       |
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#=========================================================================|
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
# Author:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#Â Â Designed and written by Michelle Dupuis on October 7, 2005Â Â Â Â Â Â Â Â Â Â Â |
#  Michelle can be reached at support@ocgca                             |
#  This script and other related tools are available for download       |
#  at www.generationd.com                                               |
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#=========================================================================|
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
# DATEÂ Â Â Â Â Â Â Â VERÂ AUTHORÂ Â Â Â Â Â Â DESCRIPTIONÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
# Oct 7 2005  1.0 M Dupuis     Original coding                        |
# Oct 9 2005  1.8 M Dupuis     Better parameter & email checking      |
# Oct 23 2005 1.9 M Dupuis     Syntax error fixes, hand ! in ID name  |
# Oct 25 2005 2.0 M Dupuis     Improved page count mechanism          |
# Nov 23 2006 2.1 J Puckett    Generalized the script & pulled vars   |
#                                from voicemail.conf                    |
# Nov 29 2006 2.2 J Puckett    Made grep use regex to find exten and  |
#                                modified documentation                 |
# May 1 2008  2.3 Asif Iqbal   Fix comment error, fix double redirect |
#Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
#=========================================================================|VERSION=’fax2mail v2.3′
LOGFILE=’/var/log/asterisk/faxlog’Â #Set to /dev/null to disable logging
DATETIME=$(date +’%A, %B %d %Y, at %I:%M %p’)
FROMEMAIL=’Asterisk PBX <[email protected]>’
DEFAULTTO=’[email protected]’echo >>$LOGFILE
echo $VERSION >>$LOGFILE
echo ‘Â Triggered on $DATETIME’>>$LOGFILE
echo ‘Â Called with $*’>>$LOGFILEif [ ${#} -le 1 ]; then
echo ‘Usage: $CMD_SCRIPT [-p | -e | -t] -f File [–cid-name <CID Name>] [–cid-number <CID Number>] [–dest-exten <Extension Called>] [–dest-name <Destination Name>] [–dest-email <Destination Email>]’
echo ‘Â No parameters were given.’>>$LOGFILE
exit 1;
fiCID_NAME=”
CID_NUMBER=”
DEST_NAME=”
DEST_EMAIL=”
DEST_EXTEN=”
FILE=”
FORMAT=’pdf’while [ ${#} -gt 0 ]; do
case ‘${1}’ in
‘–cid-name’ )
CID_NAME=${2}
shift
;;Â Â Â ‘–cid-number’ )
CID_NUMBER=${2}
shift
;;Â Â Â ‘–dest-name’ )
DEST_NAME=${2}
shift
;;Â Â Â ‘–dest-email’ )
DEST_EMAIL=${2}
shift
;;
‘–dest-exten’ )
DEST_EXTEN=${2}
shift
;;
‘–file’ | ‘-f’ )
FILE=${2}
shift
;;Â Â Â ‘-e’ )
FORMAT=’eps’
;;Â Â Â ‘-t’ )
FORMAT=’tif’
;;Â Â Â ‘-p’ )
FORMAT=’pdf’
;; esac shift
doneif [ ‘$FILE’ = ” ]; then
echo ‘Error: A file is required’
echo ‘Â No file was given.’>>>>$LOGFILE
exit 1;
fiecho ‘Â CallerID number of fax sender = $CID_NUMBER’>>$LOGFILE
echo ‘Â CallerID name of fax sender = $CID_NAME’>>$LOGFILE
echo ‘Â Fax number called = $DEST_EXTEN’>>$LOGFILE
echo ‘Â Destination name = $DEST_NAME’>>$LOGFILE
echo ‘Â Destination email address = $DEST_EMAIL’>>$LOGFILE
echo ‘Â Fax file name (without .tif extension) = $FILE’>>$LOGFILE
echo ‘Â Attachment format conversion = $FORMAT’>>$LOGFILE# Correct for missing info
if [ ‘$CID_NUMBER’ = ” ] ; then
CID_NUMBER='<unknown number>’
echo ‘Â Â Â Set CallerID number of fax sender to $CID_NUMBER’>>$LOGFILE
fi
# Must surround in quotes in case name is preceded by a !if [ ‘$CID_NAME’ = ” ] ; then
CID_NAME='<unknown name>’
echo ‘Â Â Â Set CallerID name of fax sender to $CID_NAME’>>$LOGFILE
fi
if [ ‘$DEST_EXTEN’ = ” ] ; then
DEST_EXTEN='<unknown number>’
echo ‘Â Â Â Set Fax number called to $DEST_EXTEN’>>$LOGFILE
fi# Get destination name if empty
if [ ‘$DEST_NAME’ = ” ] ; then
DEST_NAME=`egrep ‘^$DEST_EXTEN\s*=>\s*’ /etc/asterisk/voicemail.conf | cut -d, -f2`
echo ‘Â Â Â Set Destination name to $DEST_NAME’>>$LOGFILE
fi# Get destination email if empty
if [ ‘$DEST_EMAIL’ = ” ] ; then
DEST_EMAIL=`grep ‘^$DEST_EXTEN\s*=>\s*’ /etc/asterisk/voicemail.conf | cut -d, -f3-`
if [ ‘$DEST_EMAIL’ = ” ] ; then
DEST_EMAIL=$DEFAULTTO
fi
echo ‘Â Â Â Set Destination email address to $DEST_EMAIL’>>$LOGFILE
fiSOURCEFILE=$FILE.tif
DESTFILE=$FILE.$FORMAT
INFOFILE=$FILE.txt
if [ -e $SOURCEFILE ]
then
echo ‘Â Fax file $SOURCEFILE found.’>>$LOGFILEÂ # Read data from TIFF file
PAGES=$(tiffinfo $SOURCEFILE | grep ‘Page’ | cut -d ‘ ‘ -f 1)
DT=$(tiffinfo $SOURCEFILE | grep ‘Date’)
DTFAX=${DT#*:}
COUNT=${PAGES#*-}
if [ -z $COUNT ]
then
# If didn’t find a page count, use the number of occurrences of ‘spandsp’
COUNT=$(grep -c ‘spandsp’ $SOURCEFILE)
if [ -z $COUNT ]
then
COUNT='<unknown>’
fi
fi# Do any conversions requested
case ‘$FORMAT’ in
# Check if PDF conversion required
‘pdf’ )
tiff2pdf -f -p letter $SOURCEFILE > $DESTFILE
#I like to keep around for a few days & use tmpwatch to clean up
#Â Â Â rm -f $SOURCEFILE
echo ‘Â Converted $SOURCEFILE to $DESTFILE.’>>$LOGFILE
;;Â # Check if EPS conversion required
‘eps’ )
tiff2ps -2eaz -w 8.3 -h 11.7 $SOURCEFILE > $DESTFILE
#Â Â Â rm -f $SOURCEFILE
echo ‘Â Converted $SOURCEFILE to $DESTFILE.’>>$LOGFILE
;;Â # Default to leave as tif
*)
echo ‘Â No conversion of $SOURCEFILE required.’>>$LOGFILE
;;
esacecho -n >$INFOFILE
echo ‘Dear $DEST_NAME,’>>$INFOFILE
echo >>$INFOFILE
echo ‘You have just received a $COUNT page fax from $CID_NAME <$CID_NUMBER>, at phone number $DEST_EXTEN, on $DATETIME. The original fax document is attached in $FORMAT format.’>>$INFOFILE
echo >>$INFOFILE
echo >>$INFOFILE
echo >>$INFOFILE
cat $DESTFILE | mime-construct –subpart –attachment fax.$FORMAT –type application/$FORMAT –file – >$FILE.part1
cat $INFOFILE | mime-construct –header ‘From: $FROMEMAIL’ –to $DEST_EMAIL –subject ‘[PBX]: New fax from $CID_NAME <$CID_NUMBER>’ –subpart-file $FILE.part1 –file –
echo ‘Â E-mailed file to $DEST_EMAIL’>>$LOGFILE# Delete the destination file
echo ‘Â Removing destination file $DESTFILE’>>$LOGFILE
rm -f $DESTFILE# Exit with OK status code
RETVAL=0# Else tif file is missing
else
echo ‘Â Fax file $SOURCEFILE not found.’>>$LOGFILE
echo -n > $INFOFILE
echo ‘Dear $DEST_NAME,’>>$INFOFILE
echo >>$INFOFILE
echo ‘You have just received a fax attempt from $CID_NAME <$CID_NUMBER>, at phone number $DEST_EXTEN, on $DATETIME. There was a problem receiving the fax.’>>$INFOFILE
echo >>$INFOFILE
echo >>$INFOFILE
cat $INFOFILE | mime-construct –header ‘From: $FROMEMAIL’ –to $DEST_EMAIL –subject ‘[PBX]: Failed fax attempt from $CID_NAME <$CID_NUMBER>’ –file –
echo ‘Â ‘E-mailed warning to $DEST_EMAIL >>$LOGFILE
RETVAL=1
fi
# Delete the temporary message file
rm -f $FILE.part1
rm -f $INFOFILE
echo >>$LOGFILE
# exit with failure code
exit $RETVAL