I have a bash script like so:
#!/bin/bash
cd /
pwd
ls
cd Users
pwd
ls
cd robl
pwd
ls
cd Documents
pwd
ls
When I run it manually via ~/bin/script.sh
, it works as expected.
However, when I make a .plist, schedule it and start it it using launchctl
like so:
launchctl load ~/Library/LaunchAgents/com.robl.script
launchctl start com.robl.script
It fails. Specifically, it runs as expected until the last ls
, on which it throws the error
ls: .: command not found
I think this may be some kind of permission issue since the script works when running manually but not via launchctl
. Especially because all of the ls
‘s work and print the contents, except for the last one in the Documents
folder.
Any ideas?