I wrote a short shell script to write the contents of an Evernote note to a file with Geeknote, which runs under python:

#!/bin/bash
/usr/bin/python /Users/me/Git/geeknote/geeknote.py find --search "Hobbies To Do" > /dev/null
/usr/bin/python -u /Users/me/Git/geeknote/geeknote.py show "Hobbies To Do" | tee /Users/me/Programming/output.txt

The script works fine when I run it from terminal (it writes the output of the second python command to output.txt), although ideally I'd like the script to run periodically on its own. So I tried creating a .plist/LaunchAgent to run the script, but when I do that the only thing that gets written to output.txt is Input stream is empty...can't figure out why. Right 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>Label</key>
  <string>com.me.geektoolcron</string>

  <key>ProgramArguments</key>
  <array>
    <string>/Users/me/Programming/script.sh</string>
  </array>

  <key>StartInterval</key>
  <integer>10</integer>

  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>
1

There are 1 best solutions below

1
On

You could try replacing the second python command with something like echo a or replacing tee with a redirection. A script like this worked for me with the same plist:

#!/bin/bash

date | tee /tmp/f

launchd also supports directing stdout to a file:

<key>StandardOutPath</key>
<string>/Users/me/Programming/output.txt</string>