I have trying to run the below script to modify the timestamp in the Growl plist but the script is unable to update the plist.
If I execute the same thing from the command line then it works fine.
Please help.
#!/bin/sh
current=`date +"%Y-%m-%d %l:%M:%S +0000"`
cmd="defaults read com.Growl.GrowlHelperApp LastUpdateCheck -date '$current'"
echo $cmd
`$cmd`
echo `defaults read com.Growl.GrowlHelperApp LastUpdateCheck`
Don’t put the command in a variable, the quoting doesn’t work the way you think it does (see BashFAQ #050: I’m trying to put a command in a variable, but the complex cases always fail!). (And BTW the
echo $cmdis not telling you what command will actually be executed). Just run the command directly.Also, I presume you’re trying to run
defaults write ..., notdefaults read .... Finally, the echo and backquotes on the last line effectively cancel each other — just remove both. Here’s what I get:If, for some reason, you actually do need to store the command in a variable before executing it, use an array. But note that this is a bash-only feature, so start the script with
#!/bin/bash: