<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;">On Wednesday 13 May 2009 08:03:22 am Vamsi Krishna Davuluri wrote:<br>
> Thanks. I have taken into account your suggestions and made another script.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>Thank you all for helping out! Here are a few other comments: <br>
><br>
> #!/bin/bash -e<br>
> # CUPS filter to process ODT files using abiword<br>
><br>
><br>
> # $6 happens to be the path to file passed as argument<br>
> fn="$6"<br>
><br>
> #in case its not defined<br>
> TMPDIR="/tmp"<br>
See Jona's comments<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>> # we are creating a dummy folder, which can take different file types using<br>
> mkdir, change to ="/tmp/cups-odftops"<br>
> sandbox="${TMPDIR-/tmp}/cups-odftops.$$$$"<br>
> (umask 077 && mkdir "$sandbox") || exit 1<br>
><br>
> #our two dummy files<br>
> fn1="$sandbox/temp123.odt"<br>
> cp "$fn" "$fn1"<br>
Do you need to cp? Can't you symlink? Copying potentially large files is a problem. <br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>> # Call abiword quietly, securely<br>
> abiword --to="ps" "$fn1"<br>
> fn2="`echo "$fn1" | sed -e 's/odt/ps/' `"<br>
fn2=`echo "$fn1" | sed 's/\.odt$/\.ps/'`<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>> #check if our version doesn't require an intermediate conversion, if it<br>
> does, do it, else break;<br>
><br>
> if [ -n "`grep -q "%!PS-Adobe-3.0" < "$fn2" `" ];then<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>grep -q is always silent, and [ -n ] tests for string length nonzero, so this will always fail. <br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>I guess you're trying to see if the conversion failed (does not contain "%!PS-Adobe-3.0" ), so you should need: <br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>if [ -z `grep "%!PS-Adobe-3.0" < "$fn2"` ]; then<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>> abiword --to="doc" "$fn1"<br>
> abiword --to="ps" "`echo "$fn1" | sed -e 's/odt/doc/' `"<br>
> fi<br>
Again, watch out for that sed.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>-- <br>
Andrés</p></body></html>