Using launchctl with python script

I have been trying to get launchctl to run a python script for me every 3 minutes. I have read many threads and such to no avail. Following describes files and such.
PLIST file location = /Users/mike/Library/LaunchAgents
File name = scraper.plist
File owner:group = mike:staff
File contents =
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/Prope
<plist version="1.0">
<dict>
<key>Label</key>
<string>scraper</string>
<key>OnDemand</key>
<true/>
<key>Program</key>
<string>/Users/mike/scripts/python/backgroundscript/runscraper.sh</string>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/mike/scripts/python/backgroundscript</string>
<key>StartInterval</key>
<integer>3</integer>
</dict>
</plist>
SCRIPT INFO:
Location = /Users/mike/scripts/python/backgroundscript/
File name = runscraper.sh
File Contents =
#!/bin/sh
say "hey mike"
/usr/bin/python /Users/micahrye/scripts/python/backgroundscript/scraper.py
File owner:group = mike:staff (fro scraper.py and runscraper.sh)
File permissions = 755 (fro scraper.py and runscraper.sh)
NOW about the script, I have the shell script runscraper.sh call the python script. All works from the cmd line, but does not work when launchctl calls it. I put the following in the runscraper script to make sure it was getting called:
say "hey mike"
So every time launchctl calls runscraper.sh I hear the "hey mike," so I know that launchctl is calling it, BUT it does not seem to call or launch the python!!!! AGAIN, if I run runscraper.sh from the cmd line I hear "hey mike" and the python script run with no problems.
I have checked log files and found nothing.
I have tried many things and nothing has worked, would enjoy someones wisdom
thanks

Post to the Unix forum under OS X Technologies.

Similar Messages

  • Error while using pppd with chat script.

    We are using pppd with chat script to establish a connection.
    In the process we get the "Protocol reject" error.
    e.g.
    Fri Feb 26 11:35:40 2010 : Serial connection established.
    Fri Feb 26 11:35:40 2010 : Using interface ppp0
    Fri Feb 26 11:35:40 2010 : Connect: ppp0 <--> /dev/cu.usbmodem413
    Fri Feb 26 11:35:43 2010 : Remote message: PAP access OK
    Fri Feb 26 11:35:43 2010 : PAP authentication succeeded
    Fri Feb 26 11:35:43 2010 : Protocol-Reject for unsupported protocol 0x382
    Fri Feb 26 11:35:46 2010 : Protocol-Reject for unsupported protocol 0x382
    Fri Feb 26 11:35:48 2010 : local IP address 161.30.96.51
    Any inputs for resolving this error.

    Some more details:
    Tue Mar 9 13:39:34 2010 : Serial connection established.
    Tue Mar 9 13:39:34 2010 : using link 0
    Tue Mar 9 13:39:34 2010 : Using interface ppp0
    Tue Mar 9 13:39:34 2010 : Connect: ppp0 <--> /dev/cu.usbmodem413
    Tue Mar 9 13:39:35 2010 : sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x23b22dfd> <pcomp> <accomp>]
    Tue Mar 9 13:39:35 2010 : rcvd [LCP ConfRej id=0x1 <asyncmap 0x0> <magic 0x23b22dfd> <pcomp> <accomp>]
    Tue Mar 9 13:39:35 2010 : sent [LCP ConfReq id=0x2]
    Tue Mar 9 13:39:35 2010 : rcvd [LCP ConfAck id=0x2]
    Tue Mar 9 13:39:37 2010 : rcvd [LCP ConfReq id=0x34 <mru 1500> <auth pap>]
    Tue Mar 9 13:39:37 2010 : lcp_reqci: returning CONFACK.
    Tue Mar 9 13:39:37 2010 : sent [LCP ConfAck id=0x34 <mru 1500> <auth pap>]
    Tue Mar 9 13:39:37 2010 : sent [PAP AuthReq id=0x1 user="void" password=<hidden>]
    Tue Mar 9 13:39:37 2010 : rcvd [PAP AuthAck id=0x1 "PAP access OK"]
    Tue Mar 9 13:39:37 2010 : Remote message: PAP access OK
    Tue Mar 9 13:39:37 2010 : PAP authentication succeeded
    Tue Mar 9 13:39:37 2010 : sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 161.30.96.51> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
    Tue Mar 9 13:39:37 2010 : sent [ACSCP ConfReq id=0x1 <ms-dns1 0.0.0.1> <ms-dns1 0.0.0.1>]
    Tue Mar 9 13:39:37 2010 : rcvd [LCP ProtRej id=0x35 03 82 35 01 01 00 10 01 06 00 00 00 01 02 06 00 00 00]
    Tue Mar 9 13:39:37 2010 : Protocol-Reject for unsupported protocol 0x382
    Tue Mar 9 13:39:39 2010 : rcvd [IPCP ConfRej id=0x1]
    Tue Mar 9 13:39:39 2010 : sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 161.30.96.51> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
    Tue Mar 9 13:39:40 2010 : sent [ACSCP ConfReq id=0x1 <ms-dns1 0.0.0.1> <ms-dns1 0.0.0.1>]
    Tue Mar 9 13:39:40 2010 : rcvd [LCP ProtRej id=0x36 03 82 35 01 01 00 10 01 06 00 00 00 01 02 06 00 00 00]
    Tue Mar 9 13:39:40 2010 : Protocol-Reject for unsupported protocol 0x382
    Tue Mar 9 13:39:41 2010 : rcvd [IPCP ConfRej id=0x2]
    Can anyone provide help to resolve the above error ?

  • I can't paste nor copy using IDLE with Python 2.7. Can somebody fix the problem

    I can't paste nor copy using IDLE with Python 2.7.
    Can somebody fix the problem

    I just launched IDLE for Python 2.7.2 on Mac OS X 10.8.4.
    The defaults for IDLE assume a PC environment and not Mac, thus it was expecting control+c, control+v for copy and paste. Under the IDLE Options menu, Configure IDLE...
    Under the Keys tab, Use a built-in key set, select IDLE Classic Mac. Now command+c, command+v work.
    Since I didn't want to squint, I set my Font to Ubuntu Mono 14 pt.
    I applied these settings and clicked ok.
    I successfully copied from a terminal window and pasted into IDLE with no issue.

  • Blee, plugin for Maxon Cinema 4D R12 using Kuler with python

    Hi,
    I just finished Blee, a free plugin for Maxon Cinema 4D R12 using Kuler with python.
    Blee will create for you a layer of materials, each one getting the  color from the Kuler theme: you will get 5 materials in a layer named  according to the theme title.
    check here the screenshot at http://www.mediafire.com/i/?u4qkl9ebt2bb6zk

    Sweet! I'm going to download and try it out.

  • Need help with python script for Deluge

    I am using Deluge 1.3.2 with web server, and all works fine, I use this script in the Deluge settings to execute upon torrent completion:
    #!/bin/bash
    torrentid=$1
    torrentname=$2
    torrentpath=$3
    torrenttimedelta=`/usr/bin/python2 /home/bobby/scripts/deluge/torrentTimeDelta.py $1`
    subject="Started download new torrent!"
    message="$torrentname to $torrentpath"
    echo -e `date`"::Finished downloading torrent:$2 in: $3" with id:$torrentid >> ~/logs/scripts.log
    echo -e `sendEmail -t [email protected] -f [email protected] -u "deluge server notification: torrent $torrentname is complete!" -m "$torrentname has completed downloading at: $torrentpath and took $torrenttimedelta to complete :)" -xu [email protected] -xp password -v -o tls=yes -s email.com` >> ~/logs/scripts.log
    echo ---------------------------------------- >> ~/logs/scripts.log
    This is to email me when a torrent is done and works. What I wanted to add to this email was the time taken to complete the torrent. I have gotten help from Deluge forum in this thread: http://forum.deluge-torrent.org/viewtop … =9&t=36989  However I think it's something with Python within Arch that is the obstacle, and so that helpful person can't do much more IMO. The python script I'm using is:
    #!/usr/bin/python2
    from deluge.ui.client import client
    from twisted.internet import reactor
    d = client.connect()
    def on_connect_success(result):
    print "Connection was successful!"
    def on_get_torrent_value(value):
    for torrent in value:
    print "%s: %s" % (torrent, value[torrent]["name"])
    client.disconnect()
    reactor.stop()
    client.core.get_torrents_status({}, ["name"]).addCallback(on_get_torrent_value)
    d.addCallback(on_connect_success)
    def on_connect_fail(result):
    print "Connection failed!"
    print "result:", result
    d.addErrback(on_connect_fail)
    reactor.run()
    Now if I call this from shell directly, it works. However, including it with my email script at the top, Deluge itself freezes and no email is sent. I run ps aux | grep deluge and I can see that the script has run, but apparently died and all is just hanging. I kill the script process and Deluge resumes just fine, the email is sent. Kinda confused how to remedy this, appreciate any help Thanks
    P.S. When I get the email, the part that says ""$torrentname has completed downloading at: $torrentpath and took $torrenttimedelta to complete "" shows nothing where $torrenttimedelta should be, it just says "and took to complete"

    [edit]  Sorry, I don't use deluge and I messed up my test script. If the script is executable try `/home/bobby/scripts/deluge/torrentTimeDelta.py $1`
    Are there any other errors? or try running bash with debug output to see if it will tell you something else
    The problem you are having is bash doesn't recognize variables inside the tick marks.
    Hope that helps
    Last edited by rickeyski (2011-07-05 19:27:36)

  • Problem with python script [solved]

    I've been trying to run this script (with wlan0 as my interface) and it spits this out. I'm guessing this is due to some sort of syntax problem and should be pcap.somethingelse(interface) instead of pcap.pcap(interface) but I have no experience with python so I'm totally clueless.
    Traceback (most recent call last):
    File "mediaripper.py", line 143, in <module>
    pc = pcap.pcap(interface)
    AttributeError: 'module' object has no attribute 'pcap'
    Edit- NVM, I just had the wrong version of pypcap installed.
    Last edited by omgwtfbyobbq (2011-04-12 23:48:36)

    I hate to revive such an old thread, but what version of pypcap did you use? I'm having the same issue.

  • How to create a queue using CVP with ICM script(Comprehensive mode)

    Hello Guys,
    I would like to know how can I configure a queue in a comprehensive mode using micro-app at CVP + ICM environment. I work with UCCE at least 2 years, so I know how to create a queue using UCCX and/or IPIVR (I do a queue application using UCCX Editor and at ICM I use the Run external Script component), but at CVP I don't know how to create a application at Call Studio and how to call this application at ICM Script Editor to run this queue if there aren't agents available.
    Can someone help me to understand how can I do that?
    I attached the ICM Script using micro-app. This script runs ok, I call to a Route pattern and CVP route request ICM, so ICM run the script, but if there are no agents available the call drops, so I would like to know how can I create a queue to hold the call and to come back to a available agent.
    Regards,
    Eric Zapparoli
    Unified Communications
    Wittel

    Out of the check mark in the queue to skill group node you go to another run external script node, then you loop into that over and over again until the call is answered.
    david

  • [SOLVED]Recursively use makepkg with python...or bash!

    I am basically trying to build a base Archlinux system from scratch on my eee pc. I researched Pacbuild a little bit but decided to try my own had at this.
    After being completely unsuccessful at trying to write bash scripts with loops and variables and whatnot, I took a look at python. I basically just searched a bunch of python tutorials on google and came up with this. So..this being my first script and all I was wondering if this would be the right way to do this. It basically works except with no error checking and if I want it to stop i have to press ctrl-c until the loop ends...but other that it works fine.
    #! /usr/bin/env python
    #import bash commands
    import os
    import sys
    #open pkglist file
    pkglist = open('/home/rhune/list', 'r')
    pkgname = pkglist.readline() #read pkgname in file
    while len(pkgname) != 0:
    pkgname = pkgname.rstrip('\n') #delete newline
    os.chdir('/home/rhune/eeepkgs')
    os.chdir(pkgname) #cd /home/rhune/pkgname
    os.system('makepkg') #run makepkg in working dir
    os.chdir('/home/rhune/eeepkgs') #cd ../
    pkgname = pkglist.readline() #read pkgname in file
    pkglist.close() #close file
    The "list" file is a list of folders in the directory im pointing to.
    I also plan on having it accept an argument of what folder to run in and using the tempfile to create the directory list, and with some sort of error checking. But thats a whole nother project.
    Any comments or contributions appreciated!
    edit: is there a way to check if makepkg successfully compiles the package? i.e. does it return a 1 or 0 or some sort of value? Or would i have to parse the actual output of it?
    Last edited by rhune (2009-08-28 04:48:05)

    Thanks much! This works, just gotta pick a better place to store the output.
    #!/bin/bash
    cd $1
    for folder in $(find * -type d)
    do
    cd $folder
    makepkg -s
    if [ $? -gt 0 ]; then
    echo $folder >> '/home/rhune/failed'
    else
    echo $folder >> '/home/rhune/passed'
    fi
    cd ../
    done
    Also figured out this in python:
    !/usr/bin/env python
    import os
    import subprocess
    base = "/home/rhune/test/pkgs"
    failed=[]
    dir = os.listdir(base)
    dir.sort()
    os.chdir(base)
    print dir
    for x in range(len(dir)):
    os.chdir(dir[x])
    retcode = subprocess.call(['makepkg', '-s'])
    if retcode==1:
    failed.append(dir[x])
    os.chdir(base)
    print failed
    The bash one seems a bit simpler though.
    Also, this:
    #! /usr/bin/env python
    import os
    import sys
    deplist=[]
    depname=""
    count=0 #count apostrophes
    #search for depends= line in pkgbuild
    with open('/home/rhune/pkgs/yaourt/PKGBUILD', 'r') as pkg:
    for deps in pkg:
    if "depends" in deps: break
    deps=deps.strip('depends=')
    #insert depnames into deplist
    for x in deps:
    if x=="'": count+=1 #counts apostrophes
    if x.isalpha(): depname+=x
    if count==2:
    deplist.append(depname)
    depname="" #reset depname
    count=0 #reset count
    #pbget for each dependency in list
    for x in range(len(deplist)):
    os.system('pbget --arch=i686 '+deplist[x])
    Reads a PKGBUILD file and pbgets dependencies. Need to change sys to subprocess, didnt realize it was outdated. Still needs a little work, but its practically done. Also made a sed script to go through each directory and change the PKGBUILD to use gcc-4.5 for the atom optimization.
    #!/bin/bash
    cd $1
    ls -l
    for folder in $(find * -type d)
    do
    cd $folder
    sed -s 's/\.\/configure/CC=gcc-4.5 \.\/configure/' PKGBUILD > tmpfile ; mv tmpfile PKGBUILD
    cd ../
    done
    These being the first time ever writing any sort of scripts, i think im getting the hang of it. Thanks to a little (and i mean little) bit of c++ knowledge.
    So im basically ready to compile the whole system, hopefully itll all work!
    Thanks
    edit: also, maybe a stupid question, but why does $0 -gt 0 work? does the script return a 1 or 0 after each iteration or is it from makepkg?
    Last edited by rhune (2009-08-28 04:53:52)

  • Using launchctl with Authorization

    Hi there,
    I am trying to unload one of the preinstalled launchd configurations (/System/Library/LaunchDaemons/com.apple.portmap.plist) in order to load my own configuration from within an application. I use AuthorizationExecuteWithPrivileges() for this. For some reason, the unloading does not work - launchctl returns with "no such process", but if I copy the arguments to the Terminal and execute it, it works. Loading my own config works, too (though it fails because i couldn't unload the original one). Any ideas what might be the problem?
    Thanks
    Daniel

    Post to the Unix forum under OS X Technologies.

  • Hi There I am Facing Some issues in Using OTM with Open Script Please get all information from following detail.

    Hi There,
    I have created a new Open Script in following way
    File-> New-> Functional-> Oracle EBS Forms
    I have written some code and tried to link the script with OTM. That time OTM is showing script in Directory while linking. It is properly Linked and working correctly.
    Then I have created new script again but Now I have enabled Datatable plugin of script from (Script->Properties->Module->Datatable).
    This time when the Script is "NOT Visible"  in OTM direcotry when I try to link.
    I have wasted my 4 to 5 days to find solution on this .
    Please show me some way. Thanks in advance.

    a8a3425e-7553-42bc-a91a-1e93775a8853 wrote:
    Hi There,
    I have created a new Open Script in following way
    File-> New-> Functional-> Oracle EBS Forms
    I have written some code and tried to link the script with OTM. That time OTM is showing script in Directory while linking. It is properly Linked and working correctly.
    Then I have created new script again but Now I have enabled Datatable plugin of script from (Script->Properties->Module->Datatable).
    This time when the Script is "NOT Visible"  in OTM direcotry when I try to link.
    I have wasted my 4 to 5 days to find solution on this .
    Please show me some way. Thanks in advance.
    Better asked in the EBS forum: E-Business Suite

  • How to install Berkeley DB to use with Python 3?

    I have heard that Berkeley DB is a good database.
    It seems it used to included in Python 2.x standard libraries but got excluded from 3.x version.
    I want to use only Python 3.x, so I need to install Berkeley DB somehow to use it with Python 3.x.
    Could you give me a step-by-step guide how to do it?
    Thank you.

    It should be but it is not.
    setup.py gives errors:
    C:\Users\3X\Desktop\bsddb3-5.3.0>python setup.py
    Traceback (most recent call last):
    File "setup.py", line 7, in <module>
    import setup3
    File "C:\Users\3X\Desktop\bsddb3-5.3.0\setup3.py", line 322, in <module>
    db_h_lines = open(os.path.join(incdir, 'db.h'), 'r').readlines()
    FileNotFoundError: [Errno 2] No such file or directory: 'db/include\\db.h'
    I am using Windows 7 x64, Python 3.3.2.
    Thank you
    Edited by: 1009721 on Jun 6, 2013 11:23 PM

  • Is it possible to login via python script ?

    Hi,Experts !
    I want to grab some web pages with python script. and those pages need SSO when open in firefox.
    Totally have no idea how to start the job.Could you give me some advices/tips.
    Tons of thanks.

    Please check
    Using Kerberos Authentication on SAP NetWeaver AS Java - User Authentication and Single Sign-On - SAP Library (NW7.3)
    Using Kerberos Authentication for Single Sign-On - User Authentication and Single Sign-On - SAP Library (NW7.0)

  • Trouble using Run Shell Script with python in Automator

    Hi. I have a python script I want to run in Automator (update_puzzles.py). All it does is check, rearrange and update files and there is not supposed to be any input. I can get the script to run outside of Automator, in Terminal, by navigating to the right directory and typing "python update_puzzles.py"
    I must not be setting up Run Shell Script correctly. I have it set to /bin/bash and Pass Input to stdin. The command line simply reads python /pathname/update_puzzles.py (where pathname is the path to the .py file, which I got by dragging the file onto the Run Shell Script command window). There are no actions before this in my workflow and the action after is View Results.
    The log says Run Shell Script failed, and the error is "Traceback (most recent call last):"
    Any suggestions?
    Thanks so much.

    If the script is expecting to do stuff with files in the same directory as the executable, you will probably need to add a statement to change to the appropriate working directory. The shell used in the Automator *Run Shell Script* action is a generic one that does not share any of the environment variables that the Terminal uses.

  • MacPro with10.7.3. running a Python script in terminal I see a : "There is no more application memory available on your startup disk". Python uses 10G of 16G RAM and  VM =238G with 1TB free. Log: macx-swapon FAILED - 12. It only happens with larger inputs

    On my MacPro with10.7.3. while running a Python script in terminal, after a while, in several hours actually,  I see a system message for the Terminal app: "There is no more application memory available on your startup disk". Both RAM and VM appear to be fine at this point, i.e. Python uses only 10G of 16G RAM and  VM =238G with ~1TB free. Log reads: " macx-swapon FAILED - 12" multiple times. Furthermore, other terminal windows can be opened and commands run there. It only happens with larger inputs (text files), but with inputs that are about half the size everything runs smoothly.  So the issue must be the memory indeed, but where to look for the problem/fix?

    http://liulab.dfci.harvard.edu/MACS/README.html
    Have you tried with the --diag flag for diagnostics? Or changing verbose to 3 to show debug messages? Clearly one of three things is happening;
    1. You ARE running out of disk space, but once it errors out the space is reclaimed if the output file is deleted on error. When it fails, does your output have the content generated up to the point of termination?
    2. The application (Terminal) is allocated memory that you are exceeding
    3. The task within Terminal is allocated memory that you are exceeding
    I don't know anything about what this does but is there a way to maybe run a smaller test run of it? Something that takes 10 minutes? Just to see if it works.

  • Communicat​ing with Keithley 2602A using python script

    Hi everyone,
    I want to enable communication between my PC and Keithley 2602A SourceMeter Instrument so that I can send commands to the SMI without using Test Script Builder (TSB) - a scripting/remote controlling program that enables communication between itself and the host computer.
    The reason why I want to do this is because I want to program in Python to carry out a series of tasks involving other hardwares and adjusting the voltage on the SMI at the same time. I can't use TSB to do this because TSB is solely for controlling the SMI and not other hardwares. I need to use Python scripts to consolidate all the hardware control. So far, communicating with other hardwares from my PC using Python scripts is not a problem because I have readily available libraries for them.
    I have found PyVisa which I thought could solve the communication problem. So I installed PyVisa and wrote the following code to test the communication.
    import visa
    keithley = visa.instrument("COM1")  #SMI connected to COM1
    keithley.write("smua.source.output = smua.OUTPUT_ON")  #send this command to SMI
     However, the communication was not successful as I got the error message as shown below:
    C:\Documents and Settings\cho\Desktop\Python Ex>keithley_test.py
    Traceback (most recent call last):
      File "C:\Documents and Settings\cho\Desktop\Python Ex\keithley_test.py", line 2, in <module>
        keithley = visa.instrument("COM1")
      File "C:\Python26\Lib\site-packages\pyvisa\visa.py", line 292, in instrument
        return SerialInstrument(resource_name, **keyw)
      File "C:\Python26\Lib\site-packages\pyvisa\visa.py", line 680, in __init__
        "delay", "send_end", "values_format")))
      File "C:\Python26\Lib\site-packages\pyvisa\visa.py", line 358, in __init__
        "lock")))
      File "C:\Python26\Lib\site-packages\pyvisa\visa.py", line 132, in __init__
        keyw.get("lock", VI_NO_LOCK))
      File "C:\Python26\Lib\site-packages\pyvisa\vpp43.py", line 753, in open
        byref(vi))
      File "C:\Python26\Lib\site-packages\pyvisa\vpp43.py", line 398,
    in check_status raise visa_exceptions.VisaIOError, status
    pyvisa.visa_exceptions.VisaIOError: VI_ERROR_RSRC_BUSY: The resource is valid, but VISA cannot currently access it.
    Can anyone tell me what went wrong? How can I control the Keithley 2602A using a Python script run from my PC?

    Hi DavItron, this is a very old thread but it's one of the top google results when I looked up info on how to implement some Python code with PyVISA to drive the Keithley 2602A so I will post this response so that other searchers can find the info.
    You can store data in named variables in the Keithely 2602A and then "print" them to the remote interface using something like the following:
    import visa
    ps = visa.Instrument("GPIB::Address of your instrument")
    ps.write("smua.source.levelv=10")
    ps.write("smua.source.output=smua.OUTPUT_ON")
    ps.write("currenta, voltagea = smua.measure.iv()")
    ps.write("smua.source.output=smua.OUTPUT_OFF")
    current = ps.ask("print(currenta)")
    voltage = ps.ask("print(voltagea)")
    For what I do which is mostly setting and measuring a bias point, then holding that while I trigger a measurement on another instrument, this is fine for me.  If you want to do  sweeps with a lot of data points it's probably more efficient to use the buffers directly, but I haven't needed that yet.
    Hope that helps somebody!

Maybe you are looking for