Dear all
I would like to capture who executed a script to a script's variable (i.e. testing.sh), so I can save it to a log file.
testing.sh
#! bin/ksh
user=`<< code here >>` // get the info below in RED color
<<main logic>>
echo "$user execute testing.sh on `date`" >> testing.log
--END of script--
Below is output of who command in my AIX UNIX server.
devlib pts/2 Jul 28 16:41 (pc001.testing.home)
devlib pts/3 Jul 28 10:48 (pc001.testing.home)
devlib pts/6 Jul 17 11:23 (pc002.testing.home)
lisadm pts/7 Jul 24 17:50 (pc008.testing.home)
devlib pts/8 Jul 07 11:51 (pc003.testing.home)
lisadm pts/9 Jul 25 09:45 (pc001.testing.home)
sccs pts/10 Jul 25 17:38 (pc002.testing.home)
devlib pts/12 Mar 05 17:59 (pc005.testing.home)
devlib pts/13 Jul 28 10:33 (pc008.testing.home)
devlib pts/14 Jul 17 11:23 (pc009.testing.home)
The first column is UNIX account ID, which is shared by a group of peoples. The last column is the computer name that open the terminal. How can I know (e.g. pts/3, pc001.testing.home) was executed the script?
Thank you very much.