LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-12-2002, 02:42 AM   #1
Bigun
Member
 
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400

Rep: Reputation: 30
Scripts


Is there a way to run a script when a user logs in and when they log out?
 
Old 11-12-2002, 02:49 AM   #2
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
login

/home/user/.bashrc

logout

/home/user/.bash_logout
 
Old 11-12-2002, 07:54 AM   #3
Bigun
Member
 
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400

Original Poster
Rep: Reputation: 30
"/home/user/.bashrc" works, but every time I click on a new terminal window in the X Manager it runs the script, giving me an error that the partitions are already mounted. (basically when I log in with my user I want to mount two partitions, I would use the "auto" switch in my fstab, but it would give it root permissions, no r/w access).
 
Old 11-12-2002, 08:13 AM   #4
vladkrack
Member
 
Registered: Oct 2002
Location: Curitiba - Brazil
Distribution: Conectiva
Posts: 334

Rep: Reputation: 30
The right place is fstab, but to have permissons you should use chmod, try chmod 777 _mount_point_ ....

If you just don't wanna see the error add to your line a 2> /dev/null ... ( not a very wise choise )
 
Old 11-12-2002, 11:50 AM   #5
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
or you could check to see if they are already mounted in your script

I can't see why they just can't stay mounted though.

As Vladkrak says set the permissions on the files and folders


you should make the permissions 770 or 774 whatever you need, and create a group for users that should have access

Last edited by DavidPhillips; 11-12-2002 at 11:54 AM.
 
Old 11-12-2002, 12:29 PM   #6
Bigun
Member
 
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400

Original Poster
Rep: Reputation: 30
I did this, as soon as they are automounted by fstab, only root has r/w permissions. I verified this by doing a search on the web on fstab. So, how would I check to see if they are mounted in the script? Or is there a script that ONLY runs when the user logs in?
 
Old 11-12-2002, 12:38 PM   #7
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
that is what file permissions is for

if you had to use mount to set file permissions it would not be a nice world at all



chmod is a program for setting file permissions

you can give the owner, user, and other permissions for read, write, and execute

chown is for setting the owner and group of a file.
 
Old 11-12-2002, 12:41 PM   #8
Bigun
Member
 
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400

Original Poster
Rep: Reputation: 30
Again, I tried this, as soon as it's mounted it changes the permissions and ownership to root. In fact I'll try it right now and repost if it works or not. After all, stranger things have happened.
 
Old 11-12-2002, 12:53 PM   #9
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
what filesystem is on the partition?
 
Old 11-12-2002, 12:58 PM   #10
Bigun
Member
 
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400

Original Poster
Rep: Reputation: 30
vfat
 
Old 11-12-2002, 01:12 PM   #11
vladkrack
Member
 
Registered: Oct 2002
Location: Curitiba - Brazil
Distribution: Conectiva
Posts: 334

Rep: Reputation: 30
There shouldn't have problems to change permissons, as Dave just said, but if you wan't to take the other way, just add to your script something like:

mount | grep hdx > /dev/null
if [ $? == 1 ] ; then
(your mount line)
fi

ps hdx is the name of your partition ....
 
Old 11-12-2002, 01:25 PM   #12
Bigun
Member
 
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400

Original Poster
Rep: Reputation: 30
Talking

Ohhh, pretty code! What does it mean?
 
Old 11-12-2002, 01:26 PM   #13
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
I should have guessed,

use fstab to mount it like this for full permissions, adjust as needed


/dev/hda1 /win32 vfat exec,dev,suid,rw,conv=auto,uid=99,gid=99,umask=0 0 0
 
Old 11-12-2002, 01:31 PM   #14
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
note that uid is set to nobody

also umask is sort of a reversed chmod

umask=007 is like chmod 770
 
Old 11-12-2002, 01:36 PM   #15
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
vladkrack's code will check for the drive using mount ( your drive is represented as hdx )
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
VPN: Debian Scripts -> Mandriva 2006 Scripts Undefined Mandriva 0 11-30-2005 01:10 PM
Need help running scripts from scripts sdouble Linux - Newbie 3 05-31-2004 01:56 PM
What scripts would you like to see? kittani Linux - Software 1 05-20-2004 04:26 AM
Scripts? zombie killa Linux - Software 5 05-29-2003 06:19 PM
scripts mdjames0 Linux - Newbie 4 08-02-2002 10:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration