Page 1 of 1

.bash_profile

Posted: Thu Mar 12, 2015 12:38 pm
by W0rmSp17
Hello PiFriends! I need some help adding a line of code to the .bash_profile. I don't know where to find it and edit it with root permission. PLease help. Thank you

Re: .bash_profile

Posted: Thu Mar 12, 2015 12:55 pm
by RaTTuS
why do you need to ... ?
.bash_profile
can be found if created in the users home directory i.e. ~

you can edit it like
nano .bash_profile
it does not exist by default

if you want to edit the roots .bash_profile
then
sudo nano /root/.bash_profile

you do not want to edit the users .bash_profile as root - this is not a good thing

what instructions are you following
post a URL

Re: .bash_profile

Posted: Thu Mar 12, 2015 2:13 pm
by W0rmSp17
Hello, thank you for your speedy response.

http://www.instructables.com/id/Attenda ... atization/

this is the link to the instructions. The final task is to allow this code to run on boot.

"and change it's permissions to be executable the same way as before.

After that go to your root home folder (/root/) and update file .bash_profile and add following line:
[[ $(tty) == '/dev/tty1' ]] && /root/runattendance.sh"

Re: .bash_profile

Posted: Thu Mar 12, 2015 2:21 pm
by RaTTuS
OK ...
from your user account do
sudo sh
[run a root command prompt]
cd /root
nano .bash_profile
type
[[ $(tty) == '/dev/tty1' ]] && /root/runattendance.sh
and ctrl-x - to exit the editor
^ means if I am running on tty1 [i.e. the first terminal] then run the script /root/runattendance.sh
exit ; exit
reboot machine and it should all work
or at least you should be abel to see errors on the screen...
if you need to login again then eihter
ssh in or at the machine then alt-f2 to get to another terminal and login and fix things

Re: .bash_profile

Posted: Fri Mar 13, 2015 12:43 am
by W0rmSp17
Thank you again, I followed that process the first time. I thought it was weird that theres was no file to edit. Does that mean my .sh file must be saved in the /root/ or home directory?

Re: .bash_profile

Posted: Fri Mar 13, 2015 3:11 pm
by W0rmSp17
RaTTuS wrote:OK ...
from your user account do
sudo sh
[run a root command prompt]
cd /root
nano .bash_profile
type
[[ $(tty) == '/dev/tty1' ]] && /root/runattendance.sh
and ctrl-x - to exit the editor
^ means if I am running on tty1 [i.e. the first terminal] then run the script /root/runattendance.sh
exit ; exit
reboot machine and it should all work
or at least you should be abel to see errors on the screen...
if you need to login again then eihter
ssh in or at the machine then alt-f2 to get to another terminal and login and fix things
Hello, sorry to bother you again. I followed the instructions, but every time I run the .sh code (below) it says I have a syntax error.
I'm wondering if you may have some idea of the problem, or may able to point me in the right direction.
Thank you

while [ 1=1 ];
do ^ <----Right here
if [ ! "$(pgrep attendance.py)" ];
then
/root/leds.sh && cd /root/Attendance/ && /root/Attendance/attendance.py
fi
sleep 10
done

Re: .bash_profile

Posted: Fri Mar 13, 2015 3:33 pm
by RaTTuS
W0rmSp17 wrote: while [ 1=1 ];
do ^ <----Right here
if [ ! "$(pgrep attendance.py)" ];
then
/root/leds.sh && cd /root/Attendance/ && /root/Attendance/attendance.py
fi
sleep 10
done

Code: Select all

while [ 1=1 ]
do
        if [ ! "$(pgrep attendance.py)" ];
        then
                /root/leds.sh && cd /root/Attendance/ && /root/Attendance/attendance.py
        fi
        sleep 10
done

may help ?