Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BollywooD

macrumors 6502
Original poster
Apr 27, 2005
373
46
Hamburg
so I am trying to copy keys from one plist to another, and the following command works well from the command line:
Code:
defaults write com.sweetpproductions.SafariCookies `defaults read com.apple.Safari SCautomaticMode`

whereas the following post-install shell script does not?
Code:
#!/bin/sh


# remove unneeded defaults
#find all users
for arg in `ls /Users`
do

#copy preferences for all users, if it exists - ignoring the Shared folder
if [ $arg != 'Shared' ]; then
	/usr/bin/su $arg -c "/usr/bin/defaults write com.sweetpproductions.SafariCookie `/usr/bin/defaults read com.apple.Safari SCautomaticMode`"
	
fi
done
exit 0

I get the following error:
Code:
22/09/10 7:55:48 AM	defaults[895]	
Rep argument is not a dictionary
Defaults have not been changed.

can anyone tell me what I am doing wrong?
:confused:
thanks in advance.
 
Just a guess...

The man page for bash says this about double-quotes:
Enclosing characters in double quotes preserves the literal value of
all characters within the quotes, with the exception of $, `, and \.
The characters $ and ` retain their special meaning within double
quotes. ...
(Underline added for emphasis.)
So the backtick-delimited command is being evaluated from a different context. You might want to use the -x bash option, like so:
Code:
set -x
This will tell bash to echo the command-line before executing it.
 
You might want to use the -x bash option, like so:
Code:
set -x
This will tell bash to echo the command-line before executing it.


I tried, but it didn't work, but you got me on the right path, all I had to do was to escape the single quotations like so:
Code:
/usr/bin/su $arg -c "/usr/bin/defaults write com.sweetpproductions.SafariCookie \`/usr/bin/defaults read com.apple.Safari SCautomaticMode\`"

and it works great, thanks for the help.
:D
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.