All alias in .profile lost when "script" command is called

Hi,
I was trying to call "script <an ip add>" command from .profile file to log everything whenever anyone logs in to this user. I did the following at the end of .profile. 1) Extracted the IP address who logged in 2) Called script < ip add> . The problem I am facing is all, aliases etc. written in .profile gets lost after "script command is executed. Plz suggest some way so my aliases are preserved after script command executes. Note: I dont have the access to /etc/profile, as i am not the root user.

I don't see what you did that clobbered .profile. Or do you mean that the aliases inside the .profile are not visible within the script session? That's because aliases are not inherited from the environment -- they are read on entry to an interactive shell. script sessions aren't considered interactive because (I think) the output is sent to another program (ie, script). In order to make your aliases usable, you should put them in .bashrc or .kshrc (depending on your shell).

Oh, in case you are trying to implement some security system for hackers so you can monitor their activity, search for "honeypot", the name given to such mechanisms. You might find something out there that you can cater to your needs.

Hi,

I would say the standard way was to remove all Bash alias and function definitions from your ~/.bash_profile or ~/.profile and instead put them in the file ~/.bahsrc (create that file if it doesn't yet exist).
Then to your account's ~/.profile or ~/.bash_profile add these lines:

BASH_ENV=$HOME/.bashrc
if [ -f $BASH_ENV ]; then
    . $BASH_ENV
    export BASH_ENV
else
    unset BASH_ENV
fi

Now you should have your alias defs available for each shell you spawn anew.
Refer to man bash for details.

Thanks.. works welll...