Re: Command substitution into argument to convert

Lewis <[email protected]>
Newsgroups alt.comp.lang.shell.unix.bourne-bash
Organization Miskatonic U
Message-ID <[email protected]>
In message <[email protected]> Michael F. Stemper <[email protected]> wrote:
> On 13/06/2022 19.21, Lewis wrote:
>> In message <[email protected]> Michael F. Stemper <[email protected]> wrote:
>>> I'm trying to time-stamp image files as they're downloaded. The
>>> following works fine:
>> 
>>> $ convert -pointsize 20 -fill black -draw 'text 10,20 "06/13 14:13"' RadarMap.png Stamped.png
>> 
>>> However, hard-coding the time stamp would make it worthless. What
>>> I really want to use is the output of:
>> 
>>> $ date +"%m/%d %H:%M"
>> 
>> So do that.
>> 
>> $ MYDATE=$(date +"%m/%d %H:%M");convert -pointsize 20 -fill black -draw 'text 10,20 "$MYDATE"' RadarMap.png Stamped.png

> No error message is given. The text drawn on the image is:
>    $MYDATE

Then it is still a quoting issue, probably beaus you hav single quotes
around the outside. I do not use the convert tool, so I can’t tell you
specifically what the issue is, but the first thing I wold do is
eliminate the single quotes, assuming they are not required by convert.


$ MYDATE=$(date +"%m/%d %H:%M");convert -pointsize 20 -fill black -draw "text 10,20 $MYDATE" RadarMap.png Stamped.png

or maybe 

$ MYDATE=$(date +"%m/%d %H:%M");convert -pointsize 20 -fill black -draw "text 10,20 \"$MYDATE\"" RadarMap.png Stamped.png

Remember that ' and " ae very different, and ' do not usually allow
expansion of variables contained inside, but sometimes it is hard to
know when a variable is being expanded by the shell and when it is being
passed to the command.

Either way, sometimes you just have to play with the quotes and the
escapes.

-- 
Were it not for frustration and humiliation I suppose the human race
	would get ideas above its station. -Ogden Nash
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.