I have a bash script that I would like to run with a plist file on OS X. The problem is that the bash script contains sudo commands and it stops it from running. So, for example, my bash script looks like this:
#!/bin/bash sudo /opt/local/bin/bindfs -u user1 /Library/WebServer/Documents/user1 /vhosts/user1/public_html sudo /opt/local/bin/bindfs -u user2 /Library/WebServer/Documents/user2 /vhosts/user2/public_html
and my com.test.bindfs.plist file looks like this (created using Lingon):
<?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>GroupName</key> <string>admin</string> <key>Label</key> <string>com.jamespayne.bindfs</string> <key>ProgramArguments</key> <array> <string>/usr/bin/bindfs.sh</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
I checked that the script works by running it after launch and entering the password, but it does not start when it starts. The launch plugin is started, but the following error occurs:
sudo: no tty is present and the requested program is not specified
Does anyone know how to make this work or why I can get this error. Thanks.
source share