Script inside launchd plist

Hi,
playing with lauchd plists to get some feeling about how certain things works I came up with this script inside the plist
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>/bin/df -k| /usr/bin/grep /dev/ | /usr/bin/awk '{ OFS="     "; "date +%d-%b-%Y-%I:%M| getline; print $6, $1, $4, $5;}'</string>
</array>
Its close to what I try to do in my trial stage one (1), but see some unwanted and unexpected issues
1. why is there a tab at the first line?
2. Where is the first Item, is it replaced with the date or just ignored?
3. Should I see the result(s) of date as a multi word? If I keep a space between +%d-%b-%Y and %I:%M i get a wrong result.
*this is what I get*
29-May-2010-10:53
/Volumes/TimeMachine /dev/disk5s3 303667180 69%
/Volumes/RAID01 /dev/disk4 55598552 93%
/Volumes/Repository /dev/disk0s3 96066032 2%
/Volumes/Data /dev/disk0s4 506853520 40%
/Volumes/Applications /dev/disk1s4 11657776 73%
*This what I actually did expect with the current script ( not what I want );*
29-May-2010-10:53 / /dev/disk1s3 16190024 62%
29-May-2010-10:53 /Volumes/TimeMachine /dev/disk5s3 303667180 69%
29-May-2010-10:53 /Volumes/RAID01 /dev/disk4 55598552 93%
29-May-2010-10:53 /Volumes/Repository /dev/disk0s3 96066032 2%
29-May-2010-10:53 /Volumes/Data /dev/disk0s4 506853520 40%
29-May-2010-10:53 /Volumes/Applications /dev/disk1s4 11657776 73%
I thought that the date line will get printed every time for each line from the previous piped command
*This is what I want ( stage 1 )*
29-May-2010 10:53
/ /dev/disk1s3 16190024 62%
/Volumes/TimeMachine /dev/disk5s3 303667180 69%
/Volumes/RAID01 /dev/disk4 55598552 93%
/Volumes/Repository /dev/disk0s3 96066032 2%
/Volumes/Data /dev/disk0s4 506853520 40%
/Volumes/Applications /dev/disk 1s4 11657776 73%
*This is what I finally want ( stage 2 )*
29-May-2010 10:53
/ 1s3 16190024 62%
TimeMachine 5s3 303667180 69%
RAID01 4 55598552 93%
Repository 0s3 96066032 2%
Data 0s4 506853520 40%
Applications 1s4 11657776 73%
Any help or ideas are welcome.
Thanks
PS.
Here the total launchd plist script for copy>test ( check output path )
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Debug</key>
<true/>
<key>InitGroups</key>
<false/>
<key>Label</key>
<string>net.test.PlayWithMeScript2</string>
<key>LowPriorityIO</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>/bin/df -k| /usr/bin/grep /dev/ | /usr/bin/awk '{ OFS="     "; "date+%d-%b-%Y-%I:%M"| getline; print $6, $1, $4, $5;}'</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>Play With me script</string>
<key>StandardOutPath</key>
<string>/Volumes/TestBedDevelopment/TestLogs/log3.txt</string>
<key>StartInterval</key>
<integer>60</integer>
<key>WorkingDirectory</key>
<string>/</string>
</dict>
</plist>

Absolutely true, but to learn the effects of the shell created by the launchd and a comment somewhere on the web about "if it can in launchd do it there" and that I dont want to install to much, I choose for this, for now.
Then, with all due respect to whoever wrote that article, he's an idiot
Launchd has many uses, but it's not the right place to put a multi-step script with umpteen pipes and dependencies.
Besides, I'm actually surprised it even remotely works, since launchd normally requires each element in the command to be in a separate <ProgramArguments> array element. In other words, your original:
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>/bin/df -k| /usr/bin/grep /dev/ | /usr/bin/awk '{ OFS="\t"; "date+%d-%b-%Y-%I:%M"| getline; print $6, $1, $4, $5;}'</string>
</array>
should really be more like:
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>/bin/df</string>
<string>-k</string>
<string>|</string>
<string>/usr/bin/grep</string>
<string>/dev/</string>
<string>|</string>
<string>/usr/bin/awk</string>
<string>'{</string>
<string>OFS="\t";</string>
<string>"date+%d-%b-%Y-%I:%M"</string>
<string>|</string>
<string>getline;</string>
<string>print</string>
<string>$6,</string>
<string>$1,</string>
<string>$4,</string>
<string>$5;}'</string>
</array>
and now you can see why it's a really, really bad idea to do. Far easier to just:
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/myscript.sh</string>
</array>
and put all the logic in a separate file.
The first line is gone because you're using getline within your awk statement, which tells awk to skip to the next line.
I did hoped that didn't effect everything after the ;
No. As per man awk:
The ``function'' getline sets $0 to the next input record from the current input file;
so getline moves onto the next line.
How can I return a value from a launchd?
What do you mean 'return a value from launchd'? You don't normally interact with launchd, so getting a return value from it doesn't make much sense.
And why does my script keep running?
because that's what launchd is for. By default, launchd is tasked with launching a process and keeping it running. So if a process fails it automatically gets restarted. This is normally what you want for system-level processes.
Now, that said, launchd has a number of variations that you can use to tell it to launch processes at specific times, or when certain events happen, or only at boot time, etc., but you need to add them to your .plist so that launchd knows when (and when not) to launch/restart your process.

Similar Messages

  • Launchd .plist breaks when periodic daily runs

    Why does my launchd .plist break when periodic daily runs?
    I wrote a script basically 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>GroupName</key>
    <string>wheel</string>
    <key>Label</key>
    <string>MacPeter.thingy</string>
    <key>Program</key>
    <string>/usr/local/sbin/my_script</string>
    <key>ProgramArguments</key>
    <array>
    <string>/usr/local/sbin/my_script</string>
    </array>
    <key>StandardErrorPath</key>
    <string>/dev/null</string>
    <key>StandardOutPath</key>
    <string>/var/log/myotherlog.log</string>
    <key>UserName</key>
    <string>root</string>
    <key>WatchPaths</key>
    <array>
    <string>/var/log/my_log.log</string>
    </array>
    </dict>
    </plist>
    I had to do some of this at the command line with sudo to get this .plist file into /Library/LaunchAgents and launch it. The idea is that watches the log file
    my_log.log (which I have created) and when there is activity on this log file it runs my_script, outputting the results to myotherlog.log.
    In order to avoid my_log simply growing unmanageably I also modified the /etc/daily file to add my_log to the list of logs which are rotated daily at 3:15 a.m. At 3.15, periodic daily runs, it moves and gzips my_log.log to my_log.log.0.gz and it creates a fresh my_log.log using touch.
    At this point my .plist remains loaded but stops working: it nolonger watches the new my_log.log.
    As a workaround I have put the following lines in /etc/daily.local:
    launchctl unload /Library/LaunchAgents/MacPeter.thingy.plist
    launchctl load /Library/LaunchAgents/MacPeter.thingy.plist
    This solves the problem. My question:
    Is my workaround really necessary or am I missing some other point about
    using launchd and .plist files?
    G5 single processor   Mac OS X (10.4)  

    Just as a quick guess, I would say that nothing actually breaks, you just need to keep in mind that if you roll the log you need to also reopen the file handle that points to the log file. If you don't reopen the file it will continue to look at the old, possible unlinked file pointer until the process is restarted.
    Not having much to do with launchd I would assume that this is what is happening. You need to get it to reopen the log file after is it rolled.
    Seeya...Q

  • Truly required keys in launchd plist file

    I am trying to get a launchd plist to work and run all the time. I want it to shut down my Mail.app on a certain day of the week (when I am not there). Of course, I want another one to turn it on when I get in the next day. The only plist keys that are supposed to be required are the Label and ProgramArguments. However, unless I also add the StartInterval key (any setting), my script is never called in the first place. (I have not tried any other keys yet, I am still testing this thing out.)
    Without the StartInterval, the launchctl list still shows the correct plist file is running, but Mail never shuts down. I get this on the command line:
    Workaround Bonjour: Unknown error: 0
    I tried looking into the launchctl log, and it is empty as well.
    Is this a bug, or is it necessary after all to have either StartInterval or StartCalendarInterval keyed in any launchd plist for it to function?
    I appreciate any and all feedback.

    No replies - Have mostly solved through trial and error.

  • Launchd.plist quandry

    Per an earlier post, I finally got Snort® NIDS v2.8.3 compiled, installed, and configured on my Mac Pro running OS 10.5.4. It runs fine if invoked from the keyboard, in either daemon mode or non-daemon mode. I am having problems with launching it via launchd.plist, though, and am hoping that someone can look at my plist with a fresh set of eyes and perhaps be able to immediately tell me why snort isn't launching at computer bootup.
    I want to launch an occurrence of Snort in daemon mode via launchd at bootup. The command that I use to invoke Snort in daemon mode from Terminal's command line is:
      /usr/local/bin/snort -DdevI -i en2 -l /var/log/snort/ -c /usr/local/snort-2.8.3/etc/snort.conf
    This command works fine from Terminal's command line, and launches snort in daemon mode, when root.
    My /Library/LaunchDaemons/snort.plist is:
    <?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>snort</string>
    <key>ServiceDescription</key>
    <string>launch SNORT® network intrusion detection system at bootup</string>
    <key>ProgramArguments</key>
    <array>
    <string>/usr/local/bin/snort</string>
    <string>-DdevI</string>
    <string>-i en2</string>
    <string>-l /var/log/snort/</string>
    <string>-c /usr/local/snort-2.8.3/etc/snort.conf</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    </dict>
    </plist> 
    Other info of interest:
    -rwxr-xr-x 1 root wheel /usr/local/bin/snort
    -rw-r--r-- 1 root wheel /usr/local/snort-2.8.3/snort.plist
    lrwxr-xr-x 1 root wheel /Library/LaunchDaemons/snort.plist -> /usr/local/snort-2.8.3/snort.plist 
    (Note: It is common practice of mine to keep my homebrew launchd plists with the scripts or binaries themselves, and put sym links in /Library/LaunchDaemons/ or ~/Library/LaunchAgents/)
    Thanx, anybody, in advance for any help that you can provide.

    1. You should get rid of the "®" in your plist for reasons both legal and syntactic--the Snort logo is a registered trademark on the PTO's principal register, the word "snort" is not.
    It would seem that the ServiceDescription functionality, recognized in Tiger, is no longer recognized as a valid launchd.plist keyword in Leopard. The console log indicates that this is now an unrecognized key word -- in each and every one of my launchd items. That keyword, along with its string, was removed. It didn't help, however.
    2. You should not be symlinking anything.
    Symlinking launchd plists has never, ever caused me problems before, and I have probably a half dozen symlinked plists. But, in the interest of trying to get this to work properly, I rm'ed the symlink, and mv'ed the actual plist to /Library/LaunchDaemons. Didn't cure the problem, though.
    3. You should be using *launchctl load* for immediate feedback.
    Thanks for that. I can never remember that command name!
    4. You should read these cover-to-cover:
    http://developer.apple.com/macosx/launchd.html
    http://developer.apple.com/technotes/tn2005/tn2083.html
    OK - done - nothing there jumped out at me as problems with what I was doing, but, handy references to have lying around. I'm already practicing the convention discussed therein that non-user-specific, homebrew, faceless jobs should go in the /Library/LaunchDaemons folder, as would make sense for a NIDS. So I'm not sure if you had something specific in mind when citing these articles or not....

  • Launchd.plist not launching according to SetCalendarInterval

    I have created a launchd.plist that runs a shell script to connect to a remote server and back up some log files using rsync. I have configured it to run every 15 minutes, but it is running every 10 seconds. I can't figure out why. I have posted my XML to see if anyone can shed light as to why this is happening...
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Disabled</key>
    <false/>
    <key>Label</key>
    <string>com.bgserver.logs</string>
    <key>LowPriorityIO</key>
    <true/>
    <key>Nice</key>
    <integer>12</integer>
    <key>OnDemand</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
    <string>/Users/user/Documents/scripts/logs.sh</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StartCalendarInterval</key>
    <dict>
    <key>Minute</key>
    <integer>15</integer>
    </dict>
    </dict>
    </plist>
    Here is what the console is reporting...
    10/28/09 3:31:35 PM com.apple.launchd.peruser.501[140] (com.bgserver.logs) Throttling respawn: Will start in 10 seconds
    10/28/09 3:31:45 PM com.bgserver.logs[2067] receiving file list ...
    10/28/09 3:31:45 PM com.bgserver.logs[2067] done
    10/28/09 3:31:45 PM com.bgserver.logs[2067] sent 20 bytes received 6398 bytes 12836.00 bytes/sec
    10/28/09 3:31:45 PM com.bgserver.logs[2067] total size is 1008110615 speedup is 157075.51
    10/28/09 3:31:45 PM com.apple.launchd.peruser.501[140] (com.bgserver.logs) Throttling respawn: Will start in 10 seconds
    10/28/09 3:31:55 PM com.bgserver.logs[2071] receiving file list ...
    10/28/09 3:31:55 PM com.bgserver.logs[2071] done
    10/28/09 3:31:55 PM com.bgserver.logs[2071] sent 20 bytes received 6398 bytes 12836.00 bytes/sec
    10/28/09 3:31:55 PM com.bgserver.logs[2071] total size is 1008110615 speedup is 157075.51
    10/28/09 3:31:55 PM com.apple.launchd.peruser.501[140]
    Message was edited by: ScottMSEM
    Message was edited by: ScottMSEM
    Message was edited by: ScottMSEM

    Ok, I made the changes you mentioned, and now my plist looks like this....
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Disabled</key>
    <false/>
    <key>Label</key>
    <string>com.bgserver.logs</string>
    <key>LowPriorityIO</key>
    <true/>
    <key>Nice</key>
    <integer>12</integer>
    <key>Program</key>
    <array>
    <string>/Users/sford/Documents/scripts/logs.sh</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StartInterval</key>
    <integer>900</integer>
    </dict>
    </plist>
    When I type launchctl list I see com.bgserver.logs is working...
    - 0 com.bgserver.logs
    If I type launchctl start com.bgserver.logs, it runs perfectly. The script goes, and does what is expected. Then it never runs again...
    If I type launchctl list, I get the same message that it is working...
    - 0 com.bgserver.logs
    Here is my console report again...
    10/29/09 11:15:49 AM com.bgserver.logs[556] building file list ...
    10/29/09 11:15:49 AM com.bgserver.logs[556] done
    10/29/09 11:15:49 AM com.bgserver.logs[556] sent 940 bytes received 20 bytes 1920.00 bytes/sec
    10/29/09 11:15:49 AM com.bgserver.logs[556] total size is 231809 speedup is 241.47
    You can see it ran at 11:15:49 AM, so I expected it would run at 11:30:49 AM.
    Thanks!

  • Request for additional functionality of launchd.plist

    Currently, launchd isn't designed to be event-driven via the launchd.plist. To remove the burden from developers, and to make launchd actually useful (cool!) for system administrators, here's a list of useful event options that could be added to launchd.
    OnGUILogin, to launch jobs when a new GUI session starts, with options to specify Aqua or an X11 session.
    OnGUILogout, like OnGUILogin, to launch jobs when logout is done (optionally to wait until exit before loginwindow is shown), or when the Apple's rootless X11 application is given the Quit command.
    OnGUISession, to launch jobs when a user logs in via the loginwindow as a result of fast user switching.
    OnGUISessionSwtich, to launch jobs when a user switches away from his or her desktop as a result of OnGUISession being triggered, with options for the switched-to GUI session to wait to get to the desktop until the job exits.
    OnConsoleLogin, to launch jobs when login(1) is run via a console.
    OnConsoleExit, to launch jobs to completion before exit(1), well, exits.
    OnShutdown, to replace the functionality (or lack of) that SystemStarter provides by supporting the rc.shutdown.local script.
    OnVolumeMount, with options for specifying GUID, Volume Name, Mount Point, or Media Type (USB, CD, DVD), Device Node, or Bus, so that a process can launch as a result of any, or a specific, volume mounting.
    OnVolumeUnmount, like OnVolumeMount, with option to block umount from finishing so that a job can access the volume before it's gone
    OnVolumeEject, for responding to media ejects
    Properly, OnVolumeMount, OnVolumeDismount, and OnVolumeEject would have its plist published to the specified volume upon being run, and launchd would publish the current version before the media is unmounted.
    This way, a removable device may act as a source or destination repository of launchd jobs, across multiple machines. In a way, this makes the volume "intelligent", and can become self-aware.
    Imagine a flash drive that installs system updates via Installer on machines that need them. Or a CD that checks itself for integrity against a volume MD5 checksum when its inserted.
    Or better yet, a volume that uses Time Machine and asks for an update if its stale. Taking that idea further, imagine a flash drive, formatted as XFS (that Time Machine should use in the future), that takes snapshots of a user's files for instant get-away, gotta go situations where certain files are needed. Kind of like a Back-To-My-Mac via removable media. On top of that, publish a resource on the volume to make it a mobile standalone equivalent of Window's System Restore.
    Integrating this functionality for those three options with securityd's user-agent would allow a user to permit such programs to to run or not (and flag them safe as when Internet downloaded files are launched for the first time, or as when Application sandboxing signs the executable).
    I hope this interests the Apple developers that make launchd. It seems all too often Apple's administration tools could be taken so much further to make our Macs true delight.
    Hope you enjoyed reading.

    I see now that the "StartOnMount" option in the plist can respond to a volume mounting.
    After further reading the man page, trying to decipher the -S and -D options to launchtl, this is what I understand, some or all of which may be wrong:
    1. The Aqua session is created when a user initially logs in. Jobs can be sarted as a result via the RunAtLoad option.
    2. The LoginWindow session is created when a user returns to the login window. I wonder is this is triggered by Logout, Fast User Switching, and/or the Screen Saver methods.
    3. The Background, StandardIO, and System session types aren't defined beyond having their names mentioned in the manual.
    4. The -S option, in combination with the -D option, requires plists exist in the LaunchAgents folder, not the LaunchDaemons folder of the domain.
    5. The session option enables the "user" domain, which based upon the manual example probably means jobs defined in ~/Library/LaunchAgents/.
    As a response to (3) above, how does one create or manage the sessions?

  • Can someone give me an example of a very simple launchd.plist file that...

    Launches an agent and allows the agent general internet access?
    I have this simple plist but what happens is that launchd launches it and then kills it (abort) and then launches it again and does the same thing 10 times and quits. I have traced the 'action' that causes this. As soon as my app tries to get a socket and connect, it is killed.
    I did put in a socket thing in the launchd plist file, but then it seems that launchd answers the call, not the thing I want to, then my app gets stuck on a recv call thinking it has sent data to a server and is waiting for an answer which will never come.
    I do not know if they have these for macs (I am sure they do), but imagine a tool like ICQ or Instant Messenger. It loads when the user logs on, you have your contacts list, and it coordinates via some foreign server, although once a match is made direct connects to person you are chatting with.
    How would you launch an agent like that? I can't figure out the plist entries needed. I can either launch my app and have it get "locked" by a recv call cause launchd answered the connect, and accepted the send, or I can remove the socket stuff and get in this cycle of launches and aborts.
    A simple example would be of great help.

    An object is a good way to implement this. For the first, the object would look like this:
    var oT1 = {
        "5" : 0.1,
        "50" : 2,
        "75" : 6,
        "100" : 12
    To get the value associated with the 100 property, the code would look something like:
    var val = oT1["100"];
    The variable "val" would then contain the number 12.
    For the second, the value of each object property could be an array, something like:
    var oT2 = {
        "Debbie" : [5, 0, 16],
        "Carl" : [0, 20, 4],
        "Josh" : [2, 8, 19]
    To get the second item in the array for the "Josh" array, the code would look like:
    var val = oT2["Josh"][1];
    To get the last item in the "Debbie" array, you could do this:
    var val = oT2["Debbie"][2];
    Array indexes are zero-based, so the second item has an index of 1, third item is 2, etc..
    Good luck

  • Include python script inside an app

    Hi all, I'm writing an applescript app which should use a python script.
    how can I include the script inside the apple and have it called by the applescript?
    Thank you!

    Now, is there a way to let the user choose both the output file directory and the output file name (out.iso)?
    To get the filename, add this after the code to select the directory:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #E6E6EE;
    overflow: auto;">
    set outPutName to text returned of (display dialog "Now, please enter a filename:" default answer "out" with title "Enter Filename") & ".iso"</pre>
    But you need to remove "quoted form of the" from dirOutput.
    Also, "set dirOutput to POSIX path of the dirOut" is not needed.
    so, this should work:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #E6E6EE;
    overflow: auto;">
    set dirOut to (POSIX path of (choose folder with prompt "Scegli la posizione in cui salvare il file convertito"))
    set outPutName to text returned of (display dialog "Now, please enter a filename:" default answer "out" with title "Enter Filename") & ".iso"
    if outPutName is ".iso" then set outPutName to "out.iso" -- simple error check for blank name
    if outPutName contains "/" then set outPutName to "out.iso" -- simple error check for bad charater in name
    set fullPathOut to quoted form of (dirOut & outPutName)
    </pre>
    Tony

  • W3C validator and scripts inside body

    Hi all
    I'm just wondering if placing <script ...
    ></script>
    inside the body tag is considered invalid html (transitional
    4.01) ?
    I tried to validate a page and got dozens of errors that all
    point to things like:
    Line 37, Column 83: end tag for element "I" which is not
    open:
    ... your extension is</i> '+ext+'</p>';
    the html supposedly invalid is actually part of a javascript
    string in a js function. I don't
    understand how the validator thinks I am closing tags that I
    did not open. It's open somwehere else
    in the javascript function... And why does the validator try
    to validate html that's inside
    javascript functions?
    The validator however does NOT mention anything about the
    javascript being inside the body tag and
    not in the head.
    So I'm wondering what is going on.
    seb (@webtrans1.com)
    high-end web design:
    http://webtrans1.com
    Sign-up for a free beta test of SiteLander, an ingenious
    website-builder:
    http://webtrans1.com/sitelander/
    music:
    http://myspace.com/popmodelberlin

    Change this -
    var newHtml = '<p style="color:red"><i>Sorry,
    this file type is not
    supported:</i> '+ext+'</p>';
    to this -
    var newHtml = '<p style="color:red"><i>Sorry,
    this file type is not
    supported:<' + '/i> '+ext+'<' + '/p>';
    so that the closing tags are broken apart.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "(_seb_)" <[email protected]> wrote in message
    news:[email protected]...
    > Murray *ACE* wrote:
    >>> I'm just wondering if placing <script ...
    ></script>
    >>> inside the body tag is considered invalid html
    (transitional 4.01) ?
    >>
    >> It's not.
    >>
    >>> Line 37, Column 83: end tag for element "I"
    which is not open:
    >>> ... your extension is</i>
    '+ext+'</p>';
    >>
    >> You have to be devious. Can you show us the whole
    function?
    >>
    >
    > here's the whole function -but I don't see how html
    inside javascript can
    > be relevant to the validator!
    >
    > <script type="text/javascript">
    > function updateGall(){// UPDATE IMAGE, CAPTION, AND
    NAVIGATION, DEPENDING
    > ON filenum
    > var extar=files[filenum].split(".");
    > var ext=extar[extar.length-1];
    > if(/^(jpe?g|gif|png)$/i.test(ext)){
    > var newHtml = '<img src="'+files[filenum]+'" alt=""
    id="mainImg">';
    > }else if(/^(mov|mpe?g|avi)$/i.test(ext)){
    > var newHtml = '<OBJECT
    > CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
    WIDTH="320"
    > HEIGHT="256" CODEBASE="
    http://www.apple.com/qtactivex/qtplugin.cab"><PARAM
    > name="SRC" VALUE="'+files[filenum]+'"><PARAM
    name="SCALE"
    > VALUE="aspect"><embed src="'+files[filenum]+'"
    width="320" height="256"
    > scale="aspect"></embed></OBJECT>';
    > }else{
    > var newHtml = '<p
    style="color:red"><i>Sorry, this file type is not
    > supported:</i> '+ext+'</p>';
    > }
    > getId("fileDisplay").innerHTML=newHtml;
    > var o=getId("gallNav").getElementsByTagName("a");
    > for(var
    > i=0;i<o.length;i++){if(i==filenum){o
    .className="selected";}else{o.className="bla";}}
    > // image file without extension:
    > getId("caption").innerHTML=captions[filenum];
    > }
    > </script>
    >
    > The validator chokes on all the closing html tags
    > (</object>,</embed>,</p>,</i>)
    in this function, because these tags were
    > supposeldy never opened.
    >
    > ?...
    >
    > the actual page is here:
    >
    http://www.webtrans1.com/downloads/demos/image_gallery.php
    >
    > --
    > seb (@webtrans1.com)
    >
    > high-end web design:
    http://webtrans1.com
    >
    > Sign-up for a free beta test of SiteLander, an ingenious
    website-builder:
    >
    http://webtrans1.com/sitelander/
    >
    > music:
    http://myspace.com/popmodelberlin

  • Custom scripts inside a WBEM fetchlet

    Hi,
    Can I use scripts (that query CIMOM instances and get the result) inside a WBEM fetchlet just like we use scripts in a OS Fetchlet ? In the extensibility guide, there is no mention of using custom scripts inside a WBEM fetchlet. Please clarify.
    Thanks.

    Your best bet will be to use the OSLineToken fetchlet to invoke perl or some other executable which knows how to call a python script. The agent has no special handling for python.

  • Launchctl ignores parameters in given launchd.plist, doesn't pass arguments

    *Here's my plist:*
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Debug</key>
    <true/>
    <key>ExitTimeOut</key>
    <integer>0</integer>
    <key>GroupName</key>
    <string>wheel</string>
    <key>KeepAlive</key>
    <false/>
    <key>Label</key>
    <string>org.earlywine.backup.toDMG</string>
    <key>LowPriorityIO</key>
    <false/>
    <key>Program</key>
    <string>/usr/share/org.earlywine.backup/toDMG/Backup.bash</string>
    <key>ProgramArguments</key>
    <array>
    <string>/Volumes/Home</string>
    <string>/Volums/Backup/Backups</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StandardErrorPath</key>
    <string>/Library/Logs/org.earlywine.backup.toDMG/stderr.txt</string>
    <key>StandardOutPath</key>
    <string>/Library/Logs/org.earlywine.backup.toDMG/stdout.txt</string>
    <key>TimeOut</key>
    <integer>0</integer>
    <key>UserName</key>
    <string>root</string>
    <key>WorkingDirectory</key>
    <string>/usr/share/org.earlywine.backup/toDMG</string>
    </dict>
    </plist>
    *Launchctl fails to honor parameters given to it in the plist.* Specifically, as an administrator, when running sudo launchctl, then giving it the load command and following it up with a list for the job label, here's what I'm shown:
    launchd% list org.earlywine.backup.toDMG
    "Label" = "org.earlywine.backup.toDMG";
    "LimitLoadToSessionType" = "System";
    "OnDemand" = true;
    "LastExitStatus" = 0;
    "TimeOut" = 0;
    "Program" = "/usr/share/org.earlywine.backup/toDMG/Backup.bash";
    "StandardOutPath" = "/Library/Logs/org.earlywine.backup.toDMG/stdout.txt";
    "StandardErrorPath" = "/Library/Logs/org.earlywine.backup.toDMG/stderr.txt";
    "ProgramArguments" = (
    "/Volumes/Home";
    "/Volums/Backup/Backups";
    It's not clear at all based upon the man pages why the following arguments in the plist are not shown: Debug, GroupName, UserName, ExitTimeOut, LowPriorityIO, and WorkingDirectory.
    I can confirm, that as a regular user, after loading and starting the jog, Console logs that the GroupName and UserName properties are ignored (documented in the man page). This is expected, and results in errors when the stdout and stderr files are attempted to be opened.
    *When started from any user's launchctl session, the script exits as though it wasn't given arguments.* This is evidenced by the usage() I have it print to stderr. The script checks to see if it was given 2 or more parameters, and if not, prints the usage and exits.
    I'm sure the script works properly - I've given myself sudoers rights to the Bash script, and can run it by hand without issue, as in:
    % sudo /usr/share/org.earlywine.backup/toDMG/Backup.bash /Volumes/Home /Volumes/Backup/Backups
    The plist is symlinked at /Library/LaunchDaemons/org.earlywine.backup.toDMG.plist and is in the launchctl list when an administrator sudo's into a launchctl session.
    *Behavior via the rc.shutdown.local script doesn't even equal that of a sudo'd launchctl session.*
    Here's my rc.shutdown.local script:
    #!/bin/bash
    launchctl start org.earlywine.backup.toDMG
    *Console logs the following as a result of the shutdown:*
    Nov 17 21:06:19 Tiznit com.apple.SystemStarter[39]: org.earlywine.backup.toDMG: Invalid argument
    Nov 17 21:06:19 Tiznit com.apple.SystemStarter[39]: launchctl start error: No such process
    Nov 17 21:06:19 Tiznit SystemStarter[39]: /bin/sh exit status: 1
    Based upon that message, I'd say that launchctl doesn't have the job loaded start. Despite that hunch, inserting into the shutdown script "launchctl load ..." in the line above the start makes no difference.
    The manual pages for SystemStarter and launchd do not discuss the operating environment of SystemStarter and the resulting bash script that it runs.
    It would be great if I could get some assistance with this, even though I'm running Leopard on an "unsupported" Mac.

    I suggest posting to the Unix forum under OS X Technologies.

  • Launchctl ignores parameters in given launchd.plist, doesn't pass argument

    *Here's my plist:*
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Debug</key>
    <true/>
    <key>ExitTimeOut</key>
    <integer>0</integer>
    <key>GroupName</key>
    <string>wheel</string>
    <key>KeepAlive</key>
    <false/>
    <key>Label</key>
    <string>org.earlywine.backup.toDMG</string>
    <key>LowPriorityIO</key>
    <false/>
    <key>Program</key>
    <string>/usr/share/org.earlywine.backup/toDMG/Backup.bash</string>
    <key>ProgramArguments</key>
    <array>
    <string>/Volumes/Home</string>
    <string>/Volums/Backup/Backups</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StandardErrorPath</key>
    <string>/Library/Logs/org.earlywine.backup.toDMG/stderr.txt</string>
    <key>StandardOutPath</key>
    <string>/Library/Logs/org.earlywine.backup.toDMG/stdout.txt</string>
    <key>TimeOut</key>
    <integer>0</integer>
    <key>UserName</key>
    <string>root</string>
    <key>WorkingDirectory</key>
    <string>/usr/share/org.earlywine.backup/toDMG</string>
    </dict>
    </plist>
    *Launchctl fails to honor parameters given to it in the plist.* Specifically, as an administrator, when running sudo launchctl, then giving it the load command and following it up with a list for the job label, here's what I'm shown:
    launchd% list org.earlywine.backup.toDMG
    "Label" = "org.earlywine.backup.toDMG";
    "LimitLoadToSessionType" = "System";
    "OnDemand" = true;
    "LastExitStatus" = 0;
    "TimeOut" = 0;
    "Program" = "/usr/share/org.earlywine.backup/toDMG/Backup.bash";
    "StandardOutPath" = "/Library/Logs/org.earlywine.backup.toDMG/stdout.txt";
    "StandardErrorPath" = "/Library/Logs/org.earlywine.backup.toDMG/stderr.txt";
    "ProgramArguments" = (
    "/Volumes/Home";
    "/Volums/Backup/Backups";
    *It's not clear at all based upon the man pages why the following arguments in the plist are not shown*: Debug, GroupName, UserName, ExitTimeOut, LowPriorityIO, and WorkingDirectory.
    I can confirm, that as a regular user, after loading and starting the jog, Console logs that the GroupName and UserName properties are ignored (documented in the man page). This is expected, and results in errors when the stdout and stderr files are attempted to be opened.
    *When started from any user's launchctl session, the script exits as though it wasn't given arguments.* This is evidenced by the usage() I have it print to stderr. The script checks to see if it was given 2 or more parameters, and if not, prints the usage and exits.
    I'm sure the script works properly - I've given myself sudoers rights to the Bash script, and can run it by hand without issue, as in:
    % sudo /usr/share/org.earlywine.backup/toDMG/Backup.bash /Volumes/Home /Volumes/Backup/Backups
    The plist is symlinked at /Library/LaunchDaemons/org.earlywine.backup.toDMG.plist and is in the launchctl list when an administrator sudo's into a launchctl session.
    *Behavior via the rc.shutdown.local script doesn't even equal that of a sudo'd launchctl session.*
    Here's my rc.shutdown.local script:
    #!/bin/bash
    launchctl start org.earlywine.backup.toDMG
    Console logs the following as a result of the shutdown:
    Nov 17 21:06:19 Tiznit com.apple.SystemStarter39: org.earlywine.backup.toDMG: Invalid argument
    Nov 17 21:06:19 Tiznit com.apple.SystemStarter39: launchctl start error: No such process
    Nov 17 21:06:19 Tiznit SystemStarter39: /bin/sh exit status: 1
    Based upon that message, I'd say that launchctl doesn't have the job loaded start. Despite that hunch, inserting into the shutdown script "launchctl load ..." in the line above the start makes no difference.
    The manual pages for SystemStarter and launchd do not discuss the operating environment of SystemStarter and the resulting bash script that it runs.
    It would be great if I could get some assistance with this, even though I'm running Leopard on an "unsupported" Mac.

    etresoft wrote:
    The manual pages for SystemStarter and launchd do not discuss the operating environment of SystemStarter and the resulting bash script that it runs.
    What do you mean "bash script?" Are you talking about your own bash script? It would run with the user's environment. You usually don't want to rely on environment settings in system scripts like this. If you need something, you specify it on the command line. If you run another program, you provide the full path to it.
    By "the resulting bash script that it runs", I mean the fact that SystemStarter looks for the file /etc/rc.shutdown.local and executes it during shutdown (see SystemStarter's Plist and this source lines 166-170).
    The rc.shutdown.local file, as I created it, is a bash script.
    A regular user can't make launchd run as root. If you want to run as root, remove the GroupName and UserName and run launchd as root.
    My initial reason for having UserName and GroupName in the plist was so that I could ensure the job ran as root. I know now that in order to do this the job must be started by a root-owned launchd.
    My own user is not an administrator, and the script needs root privileges in order to do its job properly. I may be able to start the job as such from my own launchd via launchctl if I prefixed the script name with "sudo" in the plist.
    I now know the UserName and GroupName plist options are not necessary to run the job as root during shutdown.
    I'm sure the script works properly - I've given myself sudoers rights to the Bash script, and can run it by hand without issue, as in:
    What does that mean? When you run a program with sudo, it just runs the program as root. There are lots more way to configure sudo in sudo's config file, but I don't think you are talking about that.
    I mean that the Bash script runs properly if run it by hand in the terminal, feeding it the arguments in bash. I was trying to imply that if it's given the arguments it will do its job.
    I was also trying to point out that the plist I gave launchctl didn't effect the same as running the script via Terminal. This even when running "sudo launchctl" and loading and starting the job, which would've been done as root.
    Given Jun T.'s response to ProgramArguments (thanks), the script will probably run on shutdown if I remove Program from the plist and move it to ProgramArguments as the first entry in the String array.

  • Simple Script and Launchd error

    Hi, I 'm just trying to run a simple script tu restart afp services over night, I have try so much things but my script just refuse to run, got error 127 and now just dont know what to do next to make it work. Thanks for your help.
    My script Location: /script/afprestrat.sh
    sudo chmod a+x /script/afprestrat.sh
    The script:
    #!/bin/bash
    serveradmin stop afp
    sleep 2
    serveradmin start afp
    PLIST location :
    /Library/LaunchDaemons/com.compagny.afprestart.plist
    the Plist:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
            <key>Label</key>
            <string>com.compagny.afprestart</string>
            <key>ProgramArguments</key>
            <array>
                    <string>sh</string>
                    <string>/script/afprestart.sh</string>
            </array>
            <key>StandardErrorPath</key>
            <string>/Users/admin/Documents/script/afprestart_err.log</string>
            <key>StandardOutPath</key>
            <string>/Users/admin/Documents/script/afprestart.log</string>
            <key>StartCalendarInterval</key>
            <dict>
                    <key>Hour</key>
                    <integer>4</integer>
                    <key>Minute</key>
                    <integer>05</integer>
            </dict>
    </dict>
    </plist>
    Command:
    sudo launchctl load -w /Library/LaunchDaemons/com.compagny.afprestart.plist
    Console error:
    com.apple.launchd com.compagny.afprestart Exited with code:127
    and afp service wasnt restart.
    Any hint will be really apprciated.
    thx !!!

    Ok now I got this:
    127
    com.compagny.afprestart
    Ligne 2 and ligne 4 of the script command not found thats mean:
    serveradmin: command not found
    will try to add the full path of the serveradmin command in the script:
    #!/bin/bash
    /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin stop afp
    sleep 2
    /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin start afp
    Any better idea ?
    thanks !

  • Launchd plist xml to run job several times a day?

    I've been reading about using launchd instead of cron.
    For the life of me I can't find out how to run a script at 10AM and 2PM
    Can you use:
    <key>StartCalendarInterval</key>
    <dict>
    <key>Hour</key>
    <integer>10</integer>
    <key>Hour</key>
    <integer>14</integer>
    or maybe
    <key>StartCalendarInterval</key>
    <dict>
    <key>Hour</key>
    <integer>10</integer>
    <integer>14</integer>
    Maybe I need 2 plists?
    If I wanted to run it every X minutes, I can program that into the XML but I don't know how you could do several specified times a day... or for that matter just on Monday and Friday?
    I've Googled all night and can't find an example. What is the trick... if there IS a trick?
    Thanks,
    Al

    In Apple's system-lingo: "A daemon is a program that runs in the background as part of the overall system (that is, it is not tied to a particular user). A daemon cannot display any GUI; more specifically, it is not allowed to connect to the window server." (see Tech Note 2083)  It doesn't have to be a continuously running program, just one that doesn't interact with users directly.  Your script will probably work in either location, mind you, so the distinction might be academic.
    All enabled plists are loaded at restart or login.  Enabled plists are plists in one of the three user-accessible launchd folders (already mentioned) which are not explicitly disabled by a Disabled key set to true (it's actually a little more complicated than that - the Disabled key in the plist is 'advisory', and the system stores the real enabled list in an undisclosed location - but it usually works).  You only need to use launchctl if you are manually updating a plist and don't want to log out, or sometimes in super-tricky cases where you want to programmatically load a plist (in those cases you set the plist's Disabled key to true so it doesn't load, and then script launchctl to load it by override the Disabled key with the -F or -w options.  probably TMI).  it is set-it-and-forget-it.
    There's no simple utility for this, I think, because not that many people use launchd directly, and those few who do tend to write plists, toss them in the correct folder, and forget about them.  I have a applescript I use for loading and reloading plists which I keep in the script menu:
    on run
              tell application "Finder" to set theItems to the selection as alias list
      relaunchd(theItems)
    end run
    to relaunchd(theItems)
              repeat with thisPlistFile in theItems
                        tell application "Finder" to set containerName to displayed name of container of thisPlistFile
                        if containerName is in {"LaunchAgents", "LaunchDaemons"} then
                                  set thePath to quoted form of (POSIX path of thisPlistFile)
                                  do shell script "launchctl unload " & thePath
                                  do shell script "launchctl load " & thePath
                        end if
              end repeat
    end relaunchd
    The difference between launchd and cron is that cron is (pardon me for putting it this way) a unix-geek tool: its language is highly compressed and symbolic.  good for fast typing in a command-line environment, bad because a single mistyped character can become a major headache to diagnose and fix.  Launchd (like many things Apple) is much more verbose and 'natural language'-like, which means a lot more typing but a generally more user-friendly experience (once you wrap your head around it).  tradeoffs vs. tradeoffs.

  • Advertise Bonjour for a daemon using launchd plist

    Gents,
    How do I use launchd.. plist to make bonjour available for my daemon?
    Its hard to find what is possible en what I need to setup in the plist.
    This sounds vague for me.
    Sockets <dictionary of dictionaries... OR dictionary of array of dictionaries...>
    This optional key is used .................... sed as inputs to call getaddrinfo(3).
    Bonjour <boolean or string or array of strings>
    This optional key can be used to request that the service be registered with the
    mDNSResponder(8). If the value is boolean, the service name is inferred from
    the SockServiceName. SockServiceName. Name.
    I would like, if it is possible to have, advertise Bonjour + Bonjour text available to the client.
    Also how will the total bonjour string looks like? Where can I find a description about that?
    Any references and idea's?
    Thank you.

    doug pennington wrote:
    I don't know the what of your text you want to advertise, but it, the text has to come off of your machines web server(at least from my experience). man dns-sd shows some info. The path can be tricky. Should be dns-sd -R "My Test" http.tcp . 80 path=/~short name/directory of text(with text enclosed)/ (I used Sites) Now this very possibly could not be what you are asking.
    I hope it is possible, because if a client.app is searching for the right service or kind of notification then is has to start the daemon before it get the text.
    I also have supply a service type, with that I have to add a TXT record with meta data.
    {quote}
    The specific nature of the TXT record and how it is to be used is service type dependent. Each service type will define zero or more name/value pairs used to store meta-data about each service.{quote}
    http://developer.apple.com/mac/library/qa/qa2001/qa1306.html
    and
    http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt Page 12 chapter 6...
    Also It looks like you now about this stuff I have another question, more developing specific.
    Hope to meat you there also http://discussions.apple.com/thread.jspa?threadID=2446760&stqc=true

Maybe you are looking for