Reg sudo - finding user
by manickaraja from LinuxQuestions.org on (#534RM)
Hi,
I have a requirement to capture current user who runs a program. This program is run by a scheduler agent and that agent is spawned by a specific os user (tidaladm). That user internally run command as another service user (edwadm). Now inside program I want to capture original user (tidaladm). I tried below code snippet bot returns null.
osuser=$(who am i | awk '{print $1}')
osuser=$(ls -l $(tty) | awk '{print $3}')
Both these command return when I manually run it on terminaly. However program run thorough agent is giving this as NULL. Any idea how to get around it?
Thanks,
Manick.


I have a requirement to capture current user who runs a program. This program is run by a scheduler agent and that agent is spawned by a specific os user (tidaladm). That user internally run command as another service user (edwadm). Now inside program I want to capture original user (tidaladm). I tried below code snippet bot returns null.
osuser=$(who am i | awk '{print $1}')
osuser=$(ls -l $(tty) | awk '{print $3}')
Both these command return when I manually run it on terminaly. However program run thorough agent is giving this as NULL. Any idea how to get around it?
Thanks,
Manick.