[ale] string escaping - part 2

Christopher Bergeron christopher at bergeron.com
Thu Jun 21 08:56:06 EDT 2001


Everyone, thanks for the help!  Here's the bizarre thing:  When I echo that
to a file it works properly, but when I send it to a command, it fails.
Here is the script:

#!/bin/bash
d=`date +%D`
t="'text 50,50 \"$d\"'"
mogrify -draw $t /root/jet/max.gif
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ should work (but doesn't)

#this section below makes it work because the mogrify line above fails....
go figure?
echo mogrify -draw $t /root/jet/max.gif > /root/jet/temp.sh
chmod 755 temp.sh
/root/jet/temp.sh
rm -rf /root/jet/temp.sh



This script simply puts the current date on top of a gif image (max.gif).
The part that gets me is how when I execute the line:

mogrify -draw $t /root/jet/max.gif

in the script it fails to replace the $t with 'text "06/21/01"'

when I echo the EXACT same line to a file and then execute it, it works
fine.
Go figure...?  For those wondering, the command that I'm trying to execute
is:
bash# mogrify -draw 'text 50,50 "current_date_here"' max.gif


If you know why, I'd love to know... thanks.


Christopher Bergeron
Systems Administrator
Full Line Distributors
(770) 416-4237
mis at fullline.com


> -----Original Message-----
> From: danny at wiley.ceo.com [mailto:danny at wiley.ceo.com]On Behalf Of Danny
> Cox
> Sent: Thursday, June 21, 2001 8:49 AM
> To: Christopher Bergeron
> Cc: ale at ale.org
> Subject: Re: [ale] string escaping [continued]
>
>
> Christopher,
>
> Christopher Bergeron wrote:
> >
> > Thanks for all the tips!!!
> >
> > Here is the script:
> >
> > #!/bin/bash
> > t= "'text \"something here\"'"
> > echo $t
> >
> > But it still doesn't seem to work...
>
> 	That's because the shell is intrepreting it twice: first on the t=
> line, and again on the echo line.  Try this:
>
> #!/bin/bash
> t="'text \"something here\"'"
> echo "$t"
>
> Also, note the lack of spaces around the '='....
>
> --
> "Men occasionally stumble over the truth, but most of them pick
> themselves up and hurry off as if nothing had happened."
>    -- Winston Churchill
>
> Danny
>

--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list