W0rmSp17
Posts: 13
Joined: Tue Mar 03, 2015 2:20 pm

.bash_profile

Thu Mar 12, 2015 12:38 pm

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

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: .bash_profile

Thu Mar 12, 2015 12:55 pm

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
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

W0rmSp17
Posts: 13
Joined: Tue Mar 03, 2015 2:20 pm

Re: .bash_profile

Thu Mar 12, 2015 2:13 pm

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"

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: .bash_profile

Thu Mar 12, 2015 2:21 pm

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
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

W0rmSp17
Posts: 13
Joined: Tue Mar 03, 2015 2:20 pm

Re: .bash_profile

Fri Mar 13, 2015 12:43 am

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?

W0rmSp17
Posts: 13
Joined: Tue Mar 03, 2015 2:20 pm

Re: .bash_profile

Fri Mar 13, 2015 3:11 pm

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

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: .bash_profile

Fri Mar 13, 2015 3:33 pm

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 ?
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Return to “Beginners”