Re: Shell scripts not executing correctly
Re: Shell scripts not executing correctly
- Subject: Re: Shell scripts not executing correctly
- From: Peter Bierman <email@hidden>
- Date: Thu, 15 Mar 2007 11:05:22 -0700
If you do that, the preferences file will be created (if missing) as
root, which will prevent the user from modifying their own
preferences.
You should use 'su $USER -c defaults write...' to edit the pref
and $HOME to get the user's homedir instead of assuming it will be in /Users.
-pmb
At 3:42 PM +0000 3/15/07, Cormac Daly wrote:
Thank you both for the replies - the preferences were indeed being
written to /var/root/Library/Preferences.
I would prefer to use the user preference system instead of the root
preferences, however, so I am now running the following commands:
THEUSER=`logname`
defaults write
"$3/Users/$THEUSER/Library/Preferences/com.domain.appname"
installertestkeyPOSTFLIGHT installerteststringPOSTFLIGHT
This appears to function corretly but I have yet to extensively test
it - can anyone see a potential problem with writing user
preferences in this way?
Thanks again,
Cormac
On 15 Mar 2007, at 13:24, Steve Stockman wrote:
If your installer requires authorization, then the defaults command
is probably writing to the superuser's preferences
(/var/root/Library/Preferences). If you want the defaults to apply
to everyone, then Scott Russell's suggestion of explicitly
directing it to /Library/Preferences/com.domain.appname will take
care of that.
However, unless your installer forces the current startup disk to
be selected as the target, then you should put a "$3" on the front
of that path to make sure it goes to the correct disk.
--
Steve Stockman
Software Architect
Consumer Products - Macintosh
Symantec Corporation
Office: 402-296-4026
Fax: 402-296-2026
Email: <mailto:email@hidden>email@hidden
<http://www.symantec.com>www.symantec.com
Hello Cormac,
A couple of things to try ...
First, whether it's overkill or not, I always fully address the
plist I want to write to:
defaults write /Library/Preferences/com.domain.appname ....
Second, does the choice of quoting matter? (Probably not since you
say this works when you run it manually)
defaults write /Library/Preferences/com.domain.appname
installertestkeyPOSTFLIGHT 'installerteststringPOSTFLIGHT'
(no quotes for the property, single quotes for the value)
Finally, have you tried explicitly setting the value type?
defaults write /Library/Preferences/com.domain.appname
installertestkeyPOSTFLIGHT -string 'installerteststringPOSTFLIGHT'
`man defaults` lists: -string, -data, -int, -float, -bool,
-date, -array, and -dict
I don't know if any of those will help for certain, but they're
avenues I'd explore if I were having this trouble.
Best wishes,
Scott
--
Scott Russell
From: Cormac Daly <<mailto:email@hidden>email@hidden>
Date: Thu, 15 Mar 2007 11:21:15 +0000
To: <<mailto:email@hidden>email@hidden>
Subject: Shell scripts not executing correctly
Hi List,
I'm using PackageMaker to deliver a metapackage and wish to execute
shell scripts to write certain keys and values to the defaults
system at various stages of the installation. The scripts are
executing, however the scripts will not write to the defaults
system - here is the postflight script (currently just used for
testing) for one of my packages:
#!/bin/sh
echo "***Application postflight script***"
MYDEFAULTS=`whereis defaults`
echo DEFAULTS IS $MYDEFAULTS
defaults write com.domain.appname "installertestkeyPOSTFLIGHT"
"installerteststringPOSTFLIGHT"
open "$1/Contents/Resources/DemoInstaller.app"
I know PackageMaker is executing the script as DemoInstaller.app is
being launched, but the defaults system is not being affected - if
I run the script directly from the terminal using ./postflight, the
defaults system IS written to. Anybody got any suggestions?
Many thanks.
Cormac
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden