I recently installed opencv but before I run the python script i always have to run these two commands:
workon cv
source ~/.profile
I already tried running the commands at boot, here's my '/etc/rc.local':
#!/bin/sh -e
IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
/home/pi/boot.sh
# boot.sh contains those two commands
exit 0
but it didn't work.
I even tried using crontab -e
, but that too didn't work
Is there any other way by which i can avoid typing those commands in future?
-
I'm not sure if that is in any way specific to the Raspberry Pi. You might have more luck Stack Overflow or Unix & Linux.TobiMarg– TobiMarg2016年09月05日 18:03:12 +00:00Commented Sep 5, 2016 at 18:03
1 Answer 1
Have you made sure you're file is executable?
Try changing /home/pi/boot.sh to say this:
#!/bin/bash
workon cv
source /home/pi/profile
Then make the file executable with the following command:
chmod +x /home/pi/boot.sh
Also, rc.local is run as root so ~/profile would mean /root/profile instead of /home/pi/profile.