Solved Read user history at startup /etc/csh.login

IPTRACE

Well-Known Member

Reaction score: 24
Messages: 321

Hi, I need to run history 25 during user logging.
Of course, output depends on the specific user logging.
Generally, I've set command alone as I typed but no output at startup.

How can I do that? The following command does not work as I need.

sudo -u my_login csh -c 'history 25'
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 13,040
Messages: 39,664

The /etc/csh.login script is executed in the user's context. There's no need to sudo(8) or su(1).
 
OP
IPTRACE

IPTRACE

Well-Known Member

Reaction score: 24
Messages: 321

Yes, but I do not see any output. After log in to shell I can run the same command and see history.
 
OP
IPTRACE

IPTRACE

Well-Known Member

Reaction score: 24
Messages: 321

Right now csh -c 'h' I can see the history but not according to my patern.
I need full date.


user@serv:~ % h
1571 2019-08-09 10:19 sudo visudo
1572 2019-08-09 10:20 sudo visudo
1573 2019-08-09 10:20 man history
1574 2019-08-09 10:21 echo $SHELL

user@serv:~ % csh -c 'h'
1571 10:19 sudo visudo
1572 10:20 sudo visudo
1573 10:20 man history
1574 10:21 echo $SHELL
 
OP
IPTRACE

IPTRACE

Well-Known Member

Reaction score: 24
Messages: 321

Finally, it works as expected.

/etc/csh.login
csh -c 'set history = ( 1000000 "%h %Y-%W-%D %T %R\n" ) ; history 25'
 
Top