Forum Discussion
Spot the rookie error
Hi Mark,
I don't do PHP so I'm just shooting in the dark but to have some fun with it my guess is it should be
=>
Don :)
Close...
In the line: if ($time_adj = 3600) {
= (single '=') just assigns 3600 to $time_adj and the 'if' always evaluates true because 3600 is greater than 0, so it's always BST (D'oh). It should have been:
== (double '=') which actually tests whether $time_adj is equal to 3600 (3600 sec = 1 hr), meaning the difference between current London time and UTC is 1 hr, or BST. Otherwise the difference would be zero, or UTC/GMT.
Stupid thing gets me every time, just like remembering to end a line with a semi-colon.
- donsjgm9 years agoJunior
Well I had the right line.
I knew that the single '=' was the problem but wasn't sure how to implement the test.
Like I said, "it was just for fun" and I came close.
I've been fighting with a property list (plist) to make a Mac update during bonus hours.
There's been several ppl who have asked how.
I can't seem to find the 'bug' and it may be OS version specific. So far idk.
It's something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>YourMac.name.here.SftwrUpdt</string>
<key>ProgramArguments</key>
<array>
<string>softwareupdate</string>
<string>--Download</string>
<string>--All</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>02</integer>
<key>Minute</key>
<integer>00</integer></dict>
<key>StandardErrorPath</key>
<string>/Users/donsjgm/Library/Application\ Support</string>
<key>ProductPaths</key>
<string>/Users/donsjgm/Library/Application\ Support</string>
</dict>
</plist>- MarkJFine9 years agoProfessor
Interesting. Is it kicking off and giving an error, or just not kicking off?
If it's kicking off, it might need to be sudo'd.
Also, not sure what the '--schedule' switch really does, but it might have something to do with it.
Looking at Creating Launch Daemons and Agents:
I'm guessing you've seen the example for StartCalendarInterval. I'm also assuming the file is in the right folder (one of ~/Library/, /Library/, or /System/Library/; in either the LaunchDaemons or LaunchAgents folders) with the right permissions.
- donsjgm9 years agoJunior
It's not kicking off, it reports "Invalid property list".
it's in /Library/LaunchDaemons and should start with sudo launchctl load /Library/LaunchDaemons/YourMac.name.here.SftwrUpdt.plist
I finally got tired and set it aside for now.
I've scrutinized it for syntax errors and searched for the reason that it's invalid.
Different versions of OS X use different file locations and the finished (working) plist might be version dependant, idk.
the "softwareupdate" command works from terminal so thus far I just haven't figured it out.
I'll have to go back and study Creating Launch Daemons and Agents to see what I might be missing.
I was going to use cron but since it's depreciated and I wanted to help as many ppl as possible I went with Launchd.
Just a work in progress - I thought I would share with you.
Don :)
Related Content
- 3 years ago
- 5 years ago
- 9 years ago