Hello! I finally figured what was going wrong with my script.<br><br><br>Jonas, I have tried implementing your suggestions. using mktemp, XXXXX, and also a -m 077. The code doesnt work for some reason that way. lpr gets me a failed job. Also that code is basically ported from this guide,<br>
<a href="http://www.ibm.com/developerworks/linux/library/l-dvi-filter.html">http://www.ibm.com/developerworks/linux/library/l-dvi-filter.html</a><br><br>Jonas, Silbe, notice this<br><br>[Vamsi@localhost Desktop]$ $(abiword --to=ps /home/Vamsi/lololo.odt); if [ $? -ne 0 ];  then echo &#39;hello&#39;; else echo  &#39;what&#39;; fi<br>
hello                                                                                                                           <br>[Vamsi@localhost Desktop]$ $(abiword --to=doc /home/Vamsi/lololo.odt); if [ $? -ne 0 ];  then echo &#39;hello&#39;; else echo  &#39;what&#39;; fi<br>
what                                                                                                                             <br>[Vamsi@localhost Desktop]$ $(set -e abiword --to=doc /home/Vamsi/lololo.odt); if [ $? -ne 0 ];  then echo &#39;hello&#39;; else echo  &#39;what&#39;; fi<br>
what                                                                                                                                    <br>[Vamsi@localhost Desktop]$ $(set -e abiword --to=ps /home/Vamsi/lololo.odt); if [ $? -ne 0 ];  then echo &#39;hello&#39;; else echo  &#39;what&#39;; fi<br>
what                                                                                                                                   <br>[Vamsi@localhost Desktop]$ $(abiword --to=ps /home/Vamsi/lololo.odt); if [ $? -ne 0 ];  then echo &#39;hello&#39;; else echo  &#39;what&#39;; fi<br>
hello                                                                                                                           <br>[Vamsi@localhost Desktop]$ $(abiword --to=ps /home/Vamsi/lololo.odt); if [ $? -ne 0 ];  then echo &#39;hello&#39;; else echo  &#39;what&#39;; fi<br>
hello             <br><br>Set -e basically yields me the same case, that is even on an error it returns me a 0. But without set -e , it works great.<br><br><br>Moving on,<br><br>Its like this,<br><br>The lp user of lp group ( cups script executor) messes up with permissions when executing commands in a subshell, that&#39;s really messed up. my rationale is, in a subshell the lp user has no longer domain. Also, CUPS doesnt write to our /tmp folder, instead has its own folder defined somewhere.<br>
So what I made is,<br><br style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 51);"><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 51);">sandbox1=&quot;${TMPDIR1:-/</span>tmp<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 51);">}/</span>tempcups<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 51);">.$$$$&quot;</span><br style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 51);">
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 51);">
(</span>umask<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 51);"> 077 &amp;&amp; </span>mkdir<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 51);"> &quot;$sandbox1&quot;) || exit 1</span><br>
<br>I made another temp folder for the subshells to execute their commands<br><br><br>And, andres, it initially does try to convert to doc.<br><br><br>The algorithm is pretty much like this,<br><br>1) We try to write to some new path besides the same folder, if it works, we are running 2.6.6 and plus, if not we are on 2.6.6--<br>
    - We cannot check for ~<a href="http://somepath.ps">somepath.ps</a> here as 2.6.8 doesnt have that capability, so that would be inviting a hole as we would be skipping for 2.6.8 as well!<br><br># $fn happens to be supplied variable<br>
<span style="background-color: rgb(255, 255, 0);">$(</span>abiword<span style="background-color: rgb(255, 255, 0);"> --to=$sandbox1/temp123.doc $</span>fn<span style="background-color: rgb(255, 255, 0);">)</span><br style="background-color: rgb(255, 255, 0);">
<br># if this doesnt work, do the following, as 2.6.6- could only do operations in the same folder,<br># we are copying ;)<br><span style="background-color: rgb(255, 255, 0);">if [ &quot;$?&quot; -</span>ne<span style="background-color: rgb(255, 255, 0);"> 0 ]; </span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);">then</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">#our dummy file</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);">fn1=&quot;$sandbox/temp123.</span>odt<span style="background-color: rgb(255, 255, 0);">&quot;</span><br style="background-color: rgb(255, 255, 0);">cp<span style="background-color: rgb(255, 255, 0);"> &quot;$</span>fn<span style="background-color: rgb(255, 255, 0);">&quot; &quot;$fn1&quot;</span><br style="background-color: rgb(255, 255, 0);">
<br style="background-color: rgb(255, 255, 0);"><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);"># Call </span>abiword<span style="background-color: rgb(255, 255, 0);"> quietly, securely </span><br style="background-color: rgb(255, 255, 0);">
abiword<span style="background-color: rgb(255, 255, 0);"> --to=&quot;</span>ps<span style="background-color: rgb(255, 255, 0);">&quot; &quot;`echo &quot;$fn1&quot; | </span>sed<span style="background-color: rgb(255, 255, 0);"> -e &#39;s/</span>odt<span style="background-color: rgb(255, 255, 0);">$/doc/&#39; `&quot;</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);">fn2=&quot;`echo &quot;$fn1&quot; | </span>sed<span style="background-color: rgb(255, 255, 0);"> -e &#39;s/</span>odt<span style="background-color: rgb(255, 255, 0);">$/</span>ps<span style="background-color: rgb(255, 255, 0);">/&#39; `&quot;</span><br style="background-color: rgb(255, 255, 0);">
 <br><br>2) Now we enter the case what if we are in fact on 2.6.6+, well now come two paths again, 1) are we 2.6.8, or 2) anything other than 2.6.8<br>   (again 2.6.8 cant write to ps directly, we need an intermediate doc conversion for this effect)<br>
<br>
<span style="background-color: rgb(255, 255, 0);"># Call abiword quietly, securely </span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
#check if our version doesn&#39;t require an intermediate conversion, if it does, do it</span><br style="background-color: rgb(255, 255, 0);">
<br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
$(abiword --to=&quot;$sandbox1/<a href="http://temp123.ps">temp123.ps</a>&quot; &quot;$fn&quot;)</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
if [ &quot;$?&quot; -ne 0 ];</span><br style="background-color: rgb(255, 255, 0);">
<br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
then</span><br style="background-color: rgb(255, 255, 0);">
<br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
abiword --to=&quot;$sandbox/temp123.doc&quot; &quot;$fn&quot;</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
abiword --to=&quot;$sandbox/<a href="http://temp123.ps">temp123.ps</a>&quot; &quot;$sandbox/temp123.doc&quot;</span><br style="background-color: rgb(255, 255, 0);">
<br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
else</span><br style="background-color: rgb(255, 255, 0);">
<br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
#abiword --to=&quot;$sandbox/<a href="http://temp123.ps">temp123.ps</a>&quot; &quot;$fn&quot;</span><br style="background-color: rgb(255, 255, 0);">
<br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);">
fn2=&quot;$sandbox1/<a href="http://temp123.ps">temp123.ps</a>&quot;</span><br style="background-color: rgb(255, 255, 0);">
<br style="background-color: rgb(255, 255, 0);">Andres, script works great for ALLL cases :D<br><br><br><br style="background-color: rgb(255, 255, 0);">#!/bin/bash<br># CUPS filter to process ODT files using abiword<br><br>
<br><br># $6 happens to be the path to file passed as argument for debugging purposes i am use $1<br>fn=&quot;$6&quot;<br><br>#for our subshell convenience<br>sandbox1=&quot;${TMPDIR1:-/tmp}/tempcups.$$$$&quot;<br>(umask 077 &amp;&amp; mkdir &quot;$sandbox1&quot;) || exit 1<br>
<br><br># we are creating a dummy folder, which can take different file types.<br>sandbox=&quot;${TMPDIR:-/tmp}/t6cups-odftops.$$$$&quot;<br>(umask 077 &amp;&amp; mkdir &quot;$sandbox&quot;) || exit 1<br><br><br>#The condition which checks whether our abiword is 2.6.6+ or 2.6.6-<br>
<br>$(abiword --to=&quot;$sandbox1/temp123.doc&quot; &quot;$fn&quot;)<br><br>if [ &quot;$?&quot; -ne 0 ];<br>then<br><br>#our dummy file<br>fn1=&quot;$sandbox/temp123.odt&quot;<br>cp &quot;$fn&quot; &quot;$fn1&quot;<br><br>
# Call abiword quietly, securely <br>abiword --to=&quot;ps&quot; &quot;`echo &quot;$fn1&quot; | sed -e &#39;s/odt$/doc/&#39; `&quot;<br>fn2=&quot;`echo &quot;$fn1&quot; | sed -e &#39;s/odt$/ps/&#39; `&quot;<br><br>else<br>
<br># Call abiword quietly, securely <br>#check if our version doesn&#39;t require an intermediate conversion, if it does, do it<br><br>$(abiword --to=&quot;$sandbox1/<a href="http://temp123.ps">temp123.ps</a>&quot; &quot;$fn&quot;)<br>
if [ &quot;$?&quot; -ne 0 ];<br><br>then<br><br>abiword --to=&quot;$sandbox/temp123.doc&quot; &quot;$fn&quot;<br>abiword --to=&quot;$sandbox/<a href="http://temp123.ps">temp123.ps</a>&quot; &quot;$sandbox/temp123.doc&quot;<br>
<br>else<br><br>#abiword --to=&quot;$sandbox/<a href="http://temp123.ps">temp123.ps</a>&quot; &quot;$fn&quot;<br><br>fn2=&quot;$sandbox1/<a href="http://temp123.ps">temp123.ps</a>&quot;<br><br>fi<br><br>fi<br><br>cat &quot;$fn2&quot;<br>
<br>#remove the sandbox folder, for debugging purposes check by commenting the following line and see what is in the /tmp/ folder<br>#rm -rf $sandbox<br>#rm -rf $sandbox1<br><br>