[Sugar-devel] Quoting in shell scripts (was: Re: [sugar-devel] Recent fiddlings with Print Support)

Vamsi Krishna Davuluri vamsi.davuluri at gmail.com
Wed May 13 07:03:22 EDT 2009


Thanks. I have taken into account your suggestions and made another script.

This had been not a competition to beautify or verify the rigidity of the
script, rather to see if opensuse accepted it. Which it still doesnt
Something to do with lp user file create permissions.
Though the script works fine on ubuntu and fedora.
And also, this is my first shell script


#!/bin/bash -e
# CUPS filter to process ODT files using abiword


# $6 happens to be the path to file passed as argument
fn="$6"

#in case its not defined
TMPDIR="/tmp"

# we are creating a dummy folder, which can take different file types using
mkdir, change to ="/tmp/cups-odftops"
sandbox="${TMPDIR-/tmp}/cups-odftops.$$$$"
(umask 077 && mkdir "$sandbox") || exit 1

#our two dummy files
fn1="$sandbox/temp123.odt"
cp "$fn" "$fn1"

# Call abiword quietly, securely
abiword --to="ps" "$fn1"
fn2="`echo "$fn1" | sed -e 's/odt/ps/' `"

#check if our version doesn't require an intermediate conversion, if it
does, do it, else break;

if [ -n "`grep -q "%!PS-Adobe-3.0" < "$fn2" `" ];then
abiword --to="doc" "$fn1"
abiword --to="ps" "`echo "$fn1" | sed -e 's/odt/doc/' `"
fi

cat "$fn2"
#remove the sandbox folder, for debugging purposes check by commenting the
following line and see what is in the /tmp/ folder
#rm -rf $sandbox
#NOTES: CURSE me for not realizing that these scripts cant write to anyplace
other than tmp dirs, and wasting about 20 hrs doing all sorts of
combinations of selinux tweaking, writing sample scripts (which magically
did the job) and CHMODing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.sugarlabs.org/archive/sugar-devel/attachments/20090513/31dda4bf/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: odftops2
Type: application/octet-stream
Size: 1172 bytes
Desc: not available
Url : http://lists.sugarlabs.org/archive/sugar-devel/attachments/20090513/31dda4bf/attachment.obj 


More information about the Sugar-devel mailing list