Re: Login and auto executes
On Sun, Jul 06, 2014 at 11:26:22AM +0200, Jos Chrispijn wrote:
> (1) I have this regular user U1. After I log in to that user account, I
> would like to start a script that does some other commandlines.
> For this purpose I created .bash_profile and .bashrc in the U1 user
> folder, containing a simple test command like 'ls':
>
> .bashrc
> ls -alt
>
> In the .profile of the U1 user I put at the last line:
> [ $BASH ] && [ -f ~/.bashrc ] && . ~/.bashrc
>
> (2) I also tried putting the extra commands in the U1 .profile:
>
> --- cut ---
>
> echo '-- UPTIME --'
> uptime
> echo ''
> echo '-- Who is ONLINE --'
> who
>
> --- cut ---
>
> but this also is not executed. What do I overlook and/or is there an
> easier way of execting some after-login commands?
Are you certain that these files are in the right home directory? They
need to be in the directory that is listed in /etc/passwd for your account.
I ask because you said "folder", but the correct term is "directory". You
aren't, say, putting these files in the base of a network share instead
of your /etc/passwd home directory?
Also, are you certain you are invoking bash as a "login shell"? That is,
bash is listed as your shell in "/etc/passwd"? Because bash, like most
shells, behaves differently when you initially log in vs when you start
it after you've already logged in.
Does your /etc/passwd line for your account list bash _by_ _that_ _name_
or is it invoking bash with the name "sh"? Because that changes how bash
works as well.
Finally, if you do have a $HOME/.bash_profile script then your
$HOME/.profile script will be ignored.
Oh, one more thought: Are you certain you are actually running bash? If
you log in and run "ps" does it show bash, or does it show some other shell
running? If it doesn't show bash as running then you may have an out of
sync /etc/passwd file. In this case, unlikely though it is, you can use
the pwd_mkdb command to fix things up. See the man page for pwd_mkdb if
you get to this point.
--
Kevin P. Neal http://www.pobox.com/~kpn/
"Nonbelievers found it difficult to defend their position in \
the presense of a working computer." -- a DEC Jensen paper
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
討論串 (同標題文章)
完整討論串 (本文為第 3 之 8 篇):