Cups texttops wrapper
Hello, Im trying to create simple wrapper to texttops. It's goal it to determine if there is global CHARSET variable, and if not to extract one from LANG variable. The problem is how, can I redirect stdin (if there is any) to texttops. It'is simple, if there is a filename option given to texttops, but what should I do when the file comes from stdin? Here is my script so far:
if [ -z $CHARSET ];then
CHARSET=`expr "$LANG" : '.*\.\(.*\)'`
fi
CHARSET=${CHARSET} texttops $1 $2 $3 $4 $5 $6 &
return 0
Normally the 6-th argument is filename, but when it is not given, texttops reads from stdin. So how can I redirect it to him:
$STDIN | CHARSET=${CHARSET} texttops $1 $2 $3 $4 $5 $6 &
####
Ok, I've modified it like this, now It seems to work:
if [ ! -t 0 ];then
STDIN="read 0< | "
FILE=""
else
STDIN=""
FILE=$6
fi
if [ -z $CHARSET ];then
CHARSET=`expr "$LANG" : '.*\.\(.*\)'`
fi
$STDIN CHARSET=${CHARSET} texttops $1 $2 $3 $4 $5 $FILE &
return 0
Last edited by kofucii; 12-01-2009 at 01:15 PM.
|