From: Samir on 3 Oct 2007 02:16 Hello, I have the following part in a shell script. export TextToPrint="Does this print" textString=`echo "'text 100,250 \"$TextToPrint\"'"` echo $textString echo convert -font helvetica -fill black -pointsize 36 -draw $textString temp1/$filename temp1/$filename.new.jpg convert -font helvetica -fill black -pointsize 36 -draw $textString temp1/$filename temp1/$filename.new.jpg Output ----------- 'text 100,250 "Does this print"' convert -font helvetica -fill black -pointsize 36 -draw 'text 100,250 "Does this print"' temp1/000.jpg temp1/000.jpg.new.jpg convert: Non-conforming drawing primitive definition `text'. .... surprisingly, if I copy the echoed convert command from this output and paste it onto the shell prompt and execute it independently ...it works !! but, it does not seem to work from the shell script... any idea/help on this would be greatly appreciated.. samir
From: ramesh.thangamani on 3 Oct 2007 06:34 On Oct 3, 11:16 am, Samir <samir....(a)gmail.com> wrote: > Hello, > I have the following part in a shell script. > > export TextToPrint="Does this print" > textString=`echo "'text 100,250 \"$TextToPrint\"'"` > echo $textString > echo convert -font helvetica -fill black -pointsize 36 -draw > $textString temp1/$filename temp1/$filename.new.jpg > convert -font helvetica -fill black -pointsize 36 -draw $textString > temp1/$filename temp1/$filename.new.jpg > > Output > ----------- > 'text 100,250 "Does this print"' > convert -font helvetica -fill black -pointsize 36 -draw 'text 100,250 > "Does this print"' temp1/000.jpg temp1/000.jpg.new.jpg > convert: Non-conforming drawing primitive definition `text'. > > ... > surprisingly, > if I copy the echoed convert command from this output and paste it > onto the shell prompt and execute it independently ...it works !! > but, it does not seem to work from the shell script... > > any idea/help on this would be greatly appreciated.. > samir Hi Samir i tried in the file as follows. It works fine for me. Or your issue is something else? 1 #! /bin/sh 2 3 export TextToPrint="Does this print" 4 textString=`echo "'text 100,250 \"$TextToPrint\"'"` 5 echo $textString 6 echo convert -font helvetica -fill black -pointsize 36 -draw \ 7 $textString temp1/$filename temp1/$filename.new.jpg \ 8 convert -font helvetica -fill black -pointsize 36 -draw $textString \ 9 temp1/$filename temp1/$filename.new.jpg
From: Volker Strell on 3 Oct 2007 07:55 Samir wrote: > Hello, > I have the following part in a shell script. > > export TextToPrint="Does this print" > textString=`echo "'text 100,250 \"$TextToPrint\"'"` > echo $textString > echo convert -font helvetica -fill black -pointsize 36 -draw > $textString temp1/$filename temp1/$filename.new.jpg > convert -font helvetica -fill black -pointsize 36 -draw $textString > temp1/$filename temp1/$filename.new.jpg > > Output > ----------- > 'text 100,250 "Does this print"' > convert -font helvetica -fill black -pointsize 36 -draw 'text 100,250 > "Does this print"' temp1/000.jpg temp1/000.jpg.new.jpg > convert: Non-conforming drawing primitive definition `text'. > > ... > surprisingly, > if I copy the echoed convert command from this output and paste it > onto the shell prompt and execute it independently ...it works !! > but, it does not seem to work from the shell script... > > any idea/help on this would be greatly appreciated.. > samir > It's a quoting issue. You have to remove the single quotes from the textString definition. Otherwise they will become part of the draw command which is not what you want. When you call convert you must put $textString in doublequotes to prevent word splitting. This should work: textString=`echo "text 100,250 \"$TextToPrint\""` convert ... -draw "$textString" ...
From: Pierre Gaston on 3 Oct 2007 05:11 Samir <samir.bot(a)gmail.com> wrote: > Hello, > I have the following part in a shell script. > > export TextToPrint="Does this print" > textString=`echo "'text 100,250 \"$TextToPrint\"'"` .... > surprisingly, > if I copy the echoed convert command from this output and paste it > onto the shell prompt and execute it independently ...it works !! > but, it does not seem to work from the shell script... The problem is that when you run command "foo bar" the quotes are removed before what is inside is being passed as an argument to command. When you do: a='"foo bar" baz' command $a The quotes are quoted and sees to mean something special for the shell. Moreover as $a is not quoted the shell will perform word splitting and create three arguments "foo, bar" and baz. (with the quotes inside) A workaround with bash is to use an array: a=("foo bar" baz) command "${a[@]}" hope this helps. -- pgas(a)sdf.lonestar.org SDF Public Access UNIX System - http://sdf.lonestar.org
|
Pages: 1 Prev: exec a shell with a cmd from another shell and keep it open? Next: sed/awk insert - help gurus |