Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
script for logon
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
SeJo
Retired Dev
Retired Dev


Joined: 08 Oct 2002
Posts: 298
Location: Belgium

PostPosted: Mon Dec 02, 2002 6:08 pm    Post subject: script for logon Reply with quote

When users log on (text-mode)

i want to run a script i tried to put it in .bash_profile (didn't work)

anyone has an idea how i should do that, so the minute they logon that script must run.

in the script i wanna load up their wm and set the networking and ipchains for that user...

thanks
Back to top
View user's profile Send private message
fyerk
Apprentice
Apprentice


Joined: 17 Sep 2002
Posts: 212
Location: Atlanta, GA

PostPosted: Mon Dec 02, 2002 6:18 pm    Post subject: Reply with quote

Try using .bashrc instead of .bash_profile
_________________
-David
Back to top
View user's profile Send private message
Stormmind
Tux's lil' helper
Tux's lil' helper


Joined: 11 Aug 2002
Posts: 112
Location: Sweden

PostPosted: Mon Dec 02, 2002 6:22 pm    Post subject: Reply with quote

It all depends on the type of logon.
From 'man bash':

Code:
 When bash is invoked as an interactive login shell, or  as
       a  non-interactive shell with the --login option, it first
       reads and executes commands from the file /etc/profile, if
       that  file  exists.  After reading that file, it looks for
       ~/.bash_profile, ~/.bash_login, and  ~/.profile,  in  that
       order,  and reads and executes commands from the first one
       that exists and is readable.  The --noprofile  option  may
       be  used  when the shell is started to inhibit this behav-
       ior.

       When a login shell exits, bash reads and executes commands
       from the file ~/.bash_logout, if it exists.

       When  an  interactive  shell  that is not a login shell is
       started, bash reads and executes commands from  ~/.bashrc,
       if  that  file exists.  This may be inhibited by using the
       --norc option.  The --rcfile file option will  force  bash
       to   read  and  execute  commands  from  file  instead  of
       ~/.bashrc.


Hope that enlightened you and made you understand the
importance of reading the man pages. :wink:

// Storm
Back to top
View user's profile Send private message
SeJo
Retired Dev
Retired Dev


Joined: 08 Oct 2002
Posts: 298
Location: Belgium

PostPosted: Mon Dec 02, 2002 6:27 pm    Post subject: Reply with quote

i read the man but understand fuck of it...
how do i know that the user's login shell is the bash and not the sh?

remember i'm a n00b and took me long enough in seeting it all up and trying to add users :-]


so if i login and i'm using bash then i should write things like "exec startkde" etc in the .bash_profile...

can i write exactely the thing i would write in the console?
Back to top
View user's profile Send private message
fyerk
Apprentice
Apprentice


Joined: 17 Sep 2002
Posts: 212
Location: Atlanta, GA

PostPosted: Mon Dec 02, 2002 6:34 pm    Post subject: Reply with quote

A user's shell is typically specified in the /etc/passwd file, so use grep to look for a specific username. The last bit will be the shell.

Example: (shell is /bin/zsh)
Code:

# grep edge /etc/passwd
edge:x:1000:100::/home/edge:/bin/zsh


The important part of the man page (man 1 bash) says:
Quote:

"When an interactive shell ... is started, bash reads and executes commands from ~/.bashrc, if that file exists."


So, to have your script run, you'll need execute it in .bashrc instead of .bash_profile.
_________________
-David
Back to top
View user's profile Send private message
SeJo
Retired Dev
Retired Dev


Joined: 08 Oct 2002
Posts: 298
Location: Belgium

PostPosted: Mon Dec 02, 2002 6:35 pm    Post subject: Reply with quote

thank you my users were set on /bin/sh

what explains why it didn't work...

sorry for my ignorance...
Back to top
View user's profile Send private message
fyerk
Apprentice
Apprentice


Joined: 17 Sep 2002
Posts: 212
Location: Atlanta, GA

PostPosted: Mon Dec 02, 2002 6:38 pm    Post subject: Reply with quote

SeJo wrote:
thank you my users were set on /bin/sh

what explains why it didn't work...

To change your shell, use the usermod command.
Code:

# usermod -s /bin/bash edge

That would change edge's shell to bash.

SeJo wrote:

sorry for my ignorance...

No apologies necessary -- we were all newbies once :D
_________________
-David
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum