Shellscript not running at bootup

We are trying to run a python script to run a shell command at bootup but it does not take effect

hereis snippet of code:

Python:
import os
os.system(“lxterminal -e ‘bash -c "cd /home/pi/SX1303_hal-main/packet_forwarder ; sudo ./lora_pkt_fwd -c global_conf.json.sx1250.IN865; exec bash"’”)

And added it to the rc.local

python sudo ./home/pi/file.py

Hi @dnyanee47 ,

Thanks for your query.

The entry in the file /etc/rc.local should be

python3 /home/pi/file.py

instead of python sudo ./home/pi/file.py

If this is a typo in the forum post and your rc.local entry is correct, then run the command

sudo journalctl -u rc-local.service | tail -100

Put the screenshot or logs in the comments below. This will help debug the issue better.

we did the same but no use
sudo journalctl -u rc-local.service | tail -100

shows connected to all

attaching rc.local screenshot

/etc/rc.local file looks ok.

To debug the error, we need output screenshot of sudo journalctl -u rc-local.service | tail -100 command. please provide it.

Meanwhile, you can test the python program run_pkt_fwd.py manually. Check if there are any syntax errors or any logical errors and ensure that it is running without any errors.

We run it manually and its works as expected. Also, the same python program the functions like led control work, and the function for executing shell commands not working.


attaching screenshot of journalctl

I suggest you make these changes to the python program.

import os

# Path to the packet forwarder program
packet_forwarder_path = "/home/pi/SX1303_hal-main/packet_forwarder/lora_pkt_fwd"

# Path to the packet forwarder config file
packet_forwarder_config_path = "/home/pi/SX1303_hal-main/packet_forwarder/global_conf.json.sx1250.IN865"

# Command to start the packet forwarder program
packet_forwarder_cmd = f"{packet_forwarder_path} -c {packet_forwarder_config_path}"

# Start the packet forwarder program using os.system
os.system(packet_forwarder_cmd)