| View previous topic :: View next topic |
| Author |
Message |
SeJo Retired Dev


Joined: 08 Oct 2002 Posts: 298 Location: Belgium
|
Posted: Mon Dec 02, 2002 6:08 pm Post subject: script for logon |
|
|
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 |
|
 |
fyerk Apprentice

Joined: 17 Sep 2002 Posts: 212 Location: Atlanta, GA
|
Posted: Mon Dec 02, 2002 6:18 pm Post subject: |
|
|
Try using .bashrc instead of .bash_profile _________________ -David |
|
| Back to top |
|
 |
Stormmind Tux's lil' helper


Joined: 11 Aug 2002 Posts: 112 Location: Sweden
|
Posted: Mon Dec 02, 2002 6:22 pm Post subject: |
|
|
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.
// Storm |
|
| Back to top |
|
 |
SeJo Retired Dev


Joined: 08 Oct 2002 Posts: 298 Location: Belgium
|
Posted: Mon Dec 02, 2002 6:27 pm Post subject: |
|
|
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 |
|
 |
fyerk Apprentice

Joined: 17 Sep 2002 Posts: 212 Location: Atlanta, GA
|
Posted: Mon Dec 02, 2002 6:34 pm Post subject: |
|
|
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 |
|
 |
SeJo Retired Dev


Joined: 08 Oct 2002 Posts: 298 Location: Belgium
|
Posted: Mon Dec 02, 2002 6:35 pm Post subject: |
|
|
thank you my users were set on /bin/sh
what explains why it didn't work...
sorry for my ignorance... |
|
| Back to top |
|
 |
fyerk Apprentice

Joined: 17 Sep 2002 Posts: 212 Location: Atlanta, GA
|
Posted: Mon Dec 02, 2002 6:38 pm Post subject: |
|
|
| 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  _________________ -David |
|
| Back to top |
|
 |
|