Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 08-30-2008, 12:02 AM   #1 (permalink)
 
Super Techie

Join Date: Jul 2006

Posts: 486

ZeroShade is on a distinguished road

Default Shell Script bashrc

I've included in the bashrc file a check to see if root is logged in and change current directory to "/". But now the other others go to "/" as well... any ideas?

# Change directory to root if not already there.
if [ "$(whoami)" = "root" ]; then
cd /
fi
__________________
Live And Let Learn.
ZeroShade is offline  
Old 08-30-2008, 05:44 AM   #2 (permalink)
Greg's Avatar
 
Indeed.

Join Date: Dec 2004

Posts: 1,554

Greg is on a distinguished road

Default Re: Shell Script bashrc

What's the problem?
__________________
Greg is offline  
Old 08-30-2008, 03:44 PM   #3 (permalink)
 
Super Techie

Join Date: Jul 2006

Posts: 486

ZeroShade is on a distinguished road

Default Re: Shell Script bashrc

I have root and then the user. When I log in as root I want the directory to be changed to "/". Which it does... but it also causes the user to do the same thing?
When I log in as the user it prints this now and changes to "/" as well. Its default is to the users home directory which makes sense. But I can't find anything in the bashrc file that relates to that which happens before my script. I simply want the root to start at / and the users to start at their home directory. Any thoughts?

Could not chdir to home directory /home/user: No such file or directory
__________________
Live And Let Learn.
ZeroShade is offline  
Old 08-30-2008, 06:38 PM   #4 (permalink)
Greg's Avatar
 
Indeed.

Join Date: Dec 2004

Posts: 1,554

Greg is on a distinguished road

Default Re: Shell Script bashrc

Code:
sudo echo "cd /" >> /root/.bashrc
That should do the trick. I'm assuming your root's home directory is in the same place as mine.
__________________
Greg is offline  
Old 08-30-2008, 06:55 PM   #5 (permalink)
 
Super Techie

Join Date: Jul 2006

Posts: 486

ZeroShade is on a distinguished road

Default Re: Shell Script bashrc

Sweet.... thanks. You've been answering all my posts before anybody else gets a chance ^_^
__________________
Live And Let Learn.
ZeroShade is offline  
Old 08-30-2008, 08:26 PM   #6 (permalink)
Greg's Avatar
 
Indeed.

Join Date: Dec 2004

Posts: 1,554

Greg is on a distinguished road

Default Re: Shell Script bashrc

hehe no problem. Glad I can help.
__________________
Greg is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
http://goosh.org/ The unofical google shell. Saxon Browser & General Internet Questions 7 06-14-2008 05:27 PM
A shutdown script Nick Windows Operating Systems and Software 3 01-30-2008 03:58 PM
My log 4uvak HijackThis Logs (finished) 87 01-05-2008 11:17 PM