Using the Xamarin Studio development environment (free version) I created a console application (File-> New-> Project-> C # -> Console project).
My application listens on the UDP port, and when it receives a packet, it pulls on the web service).
The application is compiled and run from the development environment. The application runs successfully from the command line:
But I just can't figure out how to make the application start automatically when the MAC-mini is turned on and the user logs in.
Created udp.plist, put it in / Library / LaunchAgents.
<?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>UDPListener</string> <key>Program</key> <string>/usr/bin/mono</string> <key>ProgramArguments</key> <array> <string>/Users/myname/Projects/UDPListener/bin/Debug/UDPListener.exe</string> </array> <key>RunAtLoad</key> <true/> <key>LaunchOnlyOnce</key> <true/> </dict> </plist>
#правим права доступа chown root:wheel /Library/LaunchDaemons/udp.plist #правим атрибуты chmod 755 /Library/LaunchDaemons/udp.plist
The manual says:
You can activate or deactivate a running script by running the commands:
#launchctl load /Library/LaunchAgents/[имя.вашего.файла].plist #launchctl unload /Library/LaunchAgents/[имя.вашего.файла].plist
Tried these commands. Rebooted. My application won't start.
Help me please. How can I launch my application when the user is logged in?
You can create an application that launches a shell script:
- Run Automator.app
- Select document type Application
- Find the Run shell script action in the library on the left or through the search bar
- Drag this action to the stage on the right
- Paste your script
- File -> Save
Now add this application to startup:
- System Preferences -> Users & Groups
- Select User -> Login Items
- Add the file created in Automator .app to the list
When this user logs in, the program will start.