[launchd-dev] fork & exit in Shell Script

Damien Sorresso dsorresso at apple.com
Wed Oct 29 11:22:00 PDT 2008


On Oct 29, 2008, at 10:36 AM, Charles Darwin wrote:
> Hi all,
>
> I have a shell script that runs RunAtLoad. Here is the script:
>
> ########
> /bin/test -f /Volumes/tutorials || /bin/mkdir -p /Volumes/tutorials  
> && /sbin/mount_afp afp://username:password@url/tutorials/ /Volumes/ 
> tutorials/
>
>
> /bin/test -f /Volumes/homes || /bin/mkdir -p /Volumes/homes && /sbin/ 
> mount_afp afp://username:password@url/homes/ /Volumes/homes/
> ########
> and here is the plist:
>
> ------------------
> <?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>label</string>
>         <key>ProgramArguments</key>
>         <array>
>                 <string>path/to/script</string>
>         </array>
>         <key>StartCalendarInterval</key>
>         <dict>
>                 <key>RunAtLoad</key>
>                 <true/>
>         </dict>
> </dict>
> </plist>

Firstly, it is convention to use the reverse-DNS scheme for your job  
label (i.e. com.domain.something). Secondly, RunAtLoad belongs under  
the root node of the plist, not under StartCalendarInterval. Try  
restructuring your plist 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>label</string>
>         <key>ProgramArguments</key>
>         <array>
>                 <string>path/to/script</string>
>         </array>
>         <key>RunAtLoad</key>
>         <true/>
> </dict>

-- 
Damien Sorresso
BSD Engineering
Apple Inc.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2474 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/launchd-dev/attachments/20081029/7c0bec4e/attachment.bin>


More information about the launchd-dev mailing list