LaunchAgent file path issue

This is weirdly a linux question I suppose.

Im having a problem with this code the file path is fine if I don't use the ~ and put in the user /Users/tempuser/....

This will be installed on more than one computer and changing the plist for every install is going to become tedious.

Is there a symbol or another form of path I can use to run the shell script without having to do it manually for every user???? :slight_smile:

This is saved in /Users/tempuser/Library/LaunchAgents/com.test.service.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.test.service.plist</string>
	<key>ProgramArguments</key>
	<array>
		<string>~/Library/Application Support/test.sh</string>
	</array>
	<key>StartInterval</key>
	<integer>30</integer>
	<key>RunAtLoad</key>
	<true/>
	<key>OnDemand</key>
	<true/>
</dict>
</plist>

According to https://discussions.apple.com/thread/2389927?start=0&tstart=0, the tilde does not mean anything in the launchagent config.

What u can do is to do a substitution.

for f in /Users/*/Library/LaunchAgents/com.test.service.plist
do
  user=`echo $f | cut -d/ -f3`
  sed -i -e "s#~#/Users/$user#" $f
done