0

I am looking for a simple way to start a simple .exe program on every bootup using rc.local (unless there's an easier way).

Currently, the executable program I want to run is located in: /home/pi/boot and is running properly using the sudo mono command.

I am trying to make this run at boot in the rc.local and I currently just have:

sudo /home/pi/boot/EXENAME.exe

of course I have the #!/bin/sh -e at the top of the file but not sure exactly how I should get this working.

Ghanima
  • 15,855
  • 15
  • 61
  • 119
Sharks
  • 33
  • 4
  • Do not use sudo in rc.local or anything it starts unless you've intentionally changed UID. It's already running root. Throwing in sudo cannot do anything good. See also: http://raspberrypi.stackexchange.com/questions/40493/log-output-of-background-or-boot-script – goldilocks Apr 01 '16 at 14:34
  • Are you able to successfully run your exe from an interactive command shell? If so, what command line do you type to make it run? (IE. mono /home/pi/boot/EXENAME.exe) – pierce.jason Apr 01 '16 at 20:16

2 Answers2

1

.exe files will only run under mono. Prefix your file location with 'mono' in your script and it should work.

goobering
  • 10,730
  • 4
  • 39
  • 64
  • Thanks very much for you response. I now used: #!/bin/sh -e mono /home/pi/boot/EXENAME.exe exit 0 Which did not work. I also tried sudo mono which didn't work I must be doing something wrong. I also made rc.local executable by doing a "$ ls -l /etc/rc.local" but again nothing worked yet. – Sharks Apr 01 '16 at 16:07
0

You should not be using rc.local assuming you are running a recent Raspbian which uses systemd. systemd will attempt to convert a well structured sysV script to a service, so it should still work.

An alternative for this case is to use cron.

You add commands to crontab by editing with crontab -e. E.g. I have @reboot sudo python /home/pi/shutdown_daemon.py in mine to run a program at boot.

There is a good tutorial at https://www.raspberrypi.org/documentation/linux/usage/cron.md

NOTE The first thing you should do (with ANY method) is run the program manually to ensure it actually works and the correct syntax.

Milliways
  • 59,890
  • 31
  • 101
  • 209