Run script on startup

Thomas New Member Posts: 18
edited April 2017 in UP Board Linux
I would like to run the following simple script each time the up-board starts up

#!/bin/sh -
ifconfig wlan1 up
iwconfig wlan1 mode ad-hoc
iwconfig wlan1 essid "drone"
ifconfig wlan1 netmask

I put the following adhoc.service file in /lib/systemd/system and ran "systemctl daemon-reload" and "systemctl enable adhoc.service"




When I reboot or start the script with "systemctl start adhoc.service" the status shows

Process: 4225 ExecStart=/ (code=exited, status=203/EXEC)

and the script never executes. I have made sure it is executable and it runs fine if I simply do ./ but using systemctl isn't working for some reason.

Can anyone see what might be going wrong? I would greatly appreciate anyones help with this!




  • Dan O'Donovan
    Dan O'Donovan Administrator, Moderator, Emutex Posts: 241 admin
    A common problem with scripts that run fine from your interactive shell, but fail when run from a start-up script, is that environment variables such as $PATH may have different values or are not set at all within the start-up environment.

    I suggest, for example, using full absolute paths for the commands (e.g. 'iwconfig', etc.) you're running in your script. Or, alternatively, you can set a PATH variable at the top of your script for a similar effect.
  • Thomas
    Thomas New Member Posts: 18
    Thanks Dan! I put the script int /usr/bin/ since that is part of the $PATH and it works.

    Much appreciated,