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

fax script doesn't process correctly filenames with white spaces



Package: efax
Version: 0.9a-15

When I try to send a Postscript file with the fax script command I get
the following error:


# echo "This is a test" | a2ps -o "My test file.ps"
[stdin (estándar): 1 página en 1 hoja]
[Total: 1 página en 1 hoja] guardado en el fichero 'My test file.ps'
# fax send <number> My\ test\ file.ps
can't read file My

I have patched this script (fax) to allow whitespaces on filenames.
The patch for fax script is attached to the email.

I hope this helps.

-- 
,----------------------------------------------------------------------.
| Elegance and truth are inversely related.                            |
|                 -- Becker's Razor                                    |
|----------------------------------------------------------------------|
| Labs. Technician                          |                          |
| Department of Telematic Engineering       | Debian GNU/Linux Powered |
| Universidad Carlos III de Madrid          |                          |
|-------------------------------------------|                .--.      |
|                                           |               |o_o |     |
|  _________                                |      .''`.    |:_/ |     |
| |~~      @| Marcos Lorenzo de Santiago    |     : :' :   //   \ \    |
| |  ====   | E-mail:  marcos@it.uc3m.es    |     `. `'   (|     | )   |
| |  ====   | Telephone: (+34) 91-624-9959  |       `-   /'\_   _/`\   |
| |_________| Web: www.it.uc3m.es/marcos    |            \___)=(___/   |
|                                           |                          |
`----------------------------------------------------------------------'
--- fax	2005-03-17 08:28:44.798188872 +0000
+++ fax_patched	2005-03-17 08:32:04.855458544 +0000
@@ -81,7 +81,7 @@
 # conventions. Protect with single quotes for delayed evaluation.
 # Add a leading '#' to the file name to use binary format.
 
-LOCK='-x /var/lock/LCK..$DEV' 			# modern systems
+LOCK='/var/lock/LCK..$DEV' 			# modern systems
 # LOCK='-x /usr/spool/uucp/LCK..$DEV'		# older systems
 # LOCK='-x /var/lock/LCK..$DEV -x /var/spool/uucp/LCK..$DEV' # both
 # LOCK='-x #/usr/spool/uucp/LCK..$DEV'		# binary format
@@ -417,6 +417,7 @@
 	fi
 done
 
+
 # --- set any variables given on command line
 
 while : ; do
@@ -542,7 +543,7 @@
 	while [ -f ${DEVN}.stop ] ; do sleep 15 ; done
 
 	exec $NICE $EFAX -v "" -v "$VERBLOG" -d/dev/$DEV $INIT $SPKR \
-	$CLASSINIT $FCINIT $RXINIT $LOCK \
+	$CLASSINIT $FCINIT $RXINIT -x $LOCK \
 	$RXCAP -l "$FROM" $RESET \
 	$DATAINIT -g "$DCMD" $VOICEINIT -e "$VCMD" \
 	-jS0=$ANSRINGS -w -s -r "$ANSFNAME" 2>$CONSOLE >${DEVN}.$$
@@ -759,28 +760,27 @@
 	m*)
 
 	case $# in 0) echo "No files specified" ; ERR=2 ; break ;; esac
-
-	if [ ! -r $1 ] ; then echo "Can't read $1" ; ERR=2 ; break ; fi
+	if [ ! -r "$1" ] ; then echo "Can't read '$1'" ; ERR=2 ; break ; fi
 
 
-	read x <$1
+	read x <"$1"
 	case $x in
 	%!*|?%!*)
 		echo "$1 is postscript..."
 		# GS can't deal with long paths so we 'cd' 
-		DIRNAME=`dirname $1` ; BASENAME=`basename $1`
-		( cd $DIRNAME ; \
+		DIRNAME=`dirname "$1"` ; BASENAME=`basename "$1"`
+		( cd "$DIRNAME" ; \
 		$GS -q -sDEVICE=tiffg3 -r$RES -dNOPAUSE -dSAFER \
-		-sOutputFile=$BASENAME.%03d \
+		-sOutputFile="$BASENAME".%03d \
 		-sPAPERSIZE=$PAGE \
-		$BASENAME </dev/null >/dev/null )
+		"$BASENAME" </dev/null >/dev/null )
 		;;
 	II*|MM*|P4*)
 		echo "$1 is an image file..."
-		$EFIX -ve -otiffg3 -p$PAGEDIM -r$RES -n $1.%03d $1
+		$EFIX -ve -otiffg3 -p$PAGEDIM -r$RES -n "$1".%03d "$1"
 		;;
 	*)	echo "$1 is text..."
-		$EFIX -ve -otiffg3 -p$PAGEDIM -r$RES -n $1.%03d $TEXTFONT $1
+		$EFIX -ve -otiffg3 -p$PAGEDIM -r$RES -n "$1".%03d $TEXTFONT "$1"
 		;;
 	esac
 
@@ -801,7 +801,7 @@
 					
 	# look up names
 
-	case $1 in 
+	case "$1" in 
 		[A-Za-z]*) 
 		for f in $DIRFILES ; do
 			if [ -r $f ] ; then TELNO=`$LOOKUP` ; fi
@@ -836,36 +836,52 @@
 	# use `fax make' to convert files if they need to be updated
 
 	FILES=""
-	for f in $* ; do
-		case $f in -) FILES="$FILES -" ; continue ;; esac
-		if [ ! -r $f ] ; then
-	      		echo "can't read file $f" ; ERR=2 ; break 2 
+	for f in "$@" ; do
+		case "$f" in -) FILES="$FILES -" ; continue ;; esac
+		if [ ! -r "$f" ] ; then
+	      		echo "can't read file '$f'" ; ERR=2 ; break 2 
 		fi
-		case $f in
-		*.[0-9][0-9][0-9]) FILES="$FILES $f" ;;	# skip image files
-	   	*)	if echo ${f}.001: $f \; x | make -r -q -f - ; then
-				echo ${f}.nnn is up-to-date
+		case "$f" in
+		*.[0-9][0-9][0-9]) if [ -z "$FILES" ]; then # skip image files
+		                   	FILES="$f"
+				   else
+				   	FILES="$FILES|$f"
+				   fi ;;
+	   	*)	file="`echo $f| sed -e "s/ /\\\\\\ /g"`"
+			if echo ${file}.001: $file \; x | make -r -q -f - ; then
+				echo "'${f}.nnn' is up-to-date"
 			else
 	 			$RM ${f}.[0-9][0-9][0-9]
-	 			$FAX make $OPT $f
+	 			$FAX make $OPT "$f"
 			fi
-			if [ -r $f.001 ] ; then 
-                		FILES="$FILES $f.[0-9][0-9][0-9]"
+			if [ -r "$f".001 ] ; then 
+                		if [ -z "$FILES" ]; then
+					FILES="$f.[0-9][0-9][0-9]"
+				else
+					FILES="$FILES|$f.[0-9][0-9][0-9]"
+				fi
 	      		else		# something's wrong, catch it later
-	        		FILES="$FILES $f.001"
+	        		if [ -z "$FILES" ]; then
+					FILES="$f.001"
+				else
+					FILES="$FILES|$f.001"
+				fi
 	      		fi
 			;;
 		esac
         done
 
 	# check that all files are OK
-
-	for f in $FILES ; do
-		case $f in -) continue ;; esac
-		if [ ! -r $f ] ; then
+	BACKIFS=$IFS;
+	IFS='|'
+	set -- $FILES
+	for f; do
+		case "$f" in -) continue ;; esac
+		if [ ! -r "`echo $f`" ] ; then
 	      		echo "can't read file $f" ; ERR=2 ; break 2 
    	   	fi
 	done
+	IFS=$BACKIFS
 
 	# send it
 
@@ -886,15 +902,19 @@
 
 		DATE=`eval "$DATECMD"`
 		eval HDR=\"$HDR\"
+		
+		BACKIFS=$IFS;
+		IFS='|'
+		set -- $FILES
 
 		$NICE $EFAX -v "$VERB" -v "$VERBLOG" \
-		-d/dev/$DEV $LOCK $INIT $SPKR \
+		-d/dev/$DEV -x "$LOCK" $INIT $SPKR \
 		$CLASSINIT $FCINIT $TXINIT \
 		$TXCAP -l "$FROM" $RESET $HDRFONT -h "$HDR" \
-		$MANINIT -t "$TELNO" $FILES >$logfile
+		$MANINIT -t "$TELNO" $@ >$logfile
 
 		ERR=$?
-
+                IFS=$BACKIFS
 		case $ERR in
 		0)	$RM $logfile ; break 2 ;;
 		1)	echo Busy... ;;
@@ -917,7 +937,7 @@
 # fax hangup : hang up the phone
 
 	hangup*)
-	$NICE exec $EFAX -v $VERB -d/dev/$DEV $LOCK -iZ -T 
+	$NICE exec $EFAX -v $VERB -d/dev/$DEV -x $LOCK -iZ -T 
 	break
 	;;
 
@@ -928,7 +948,7 @@
  	cd $FAXDIR
  	case $? in 0) ;; *) echo "cannot cd to $FAXDIR" ; break ;; esac
  
-	$NICE exec $EFAX -v $VERB -d/dev/$DEV $LOCK $INIT \
+	$NICE exec $EFAX -v $VERB -d/dev/$DEV -x $LOCK $INIT \
 		-j#CLS=8 -a#VLS=1 -e "$VCMD $*"
 
 	break
@@ -974,7 +994,7 @@
 	case $1 in '') file=`$TSTAMP` ;; *) file=$1 ;; esac
 	logfile=${file}.log
 
-	$NICE $EFAX -v "$VERB" -v "$VERBLOG" -d/dev/$DEV $LOCK $INIT $SPKR \
+	$NICE $EFAX -v "$VERB" -v "$VERBLOG" -d/dev/$DEV -x $LOCK $INIT $SPKR \
 	$CLASSINIT $FCINIT $RXINIT \
 	$RXCAP -l "$FROM" $RESET \
 	-r $file >$logfile

Attachment: pgpiBNoaPfLQq.pgp
Description: PGP signature


Reply to: