Reg sudo - finding user
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. |
Quote:
|
The command I have pasted is part of a shell script. Agent calls this shell script. Please let me know if it doesnt answer your question.
|
Quote:
Quote:
The fork/exec type of calls can only execute pure binaries, not scripts. There are, of course in Linux, other ways possible, but - as I said - not all of them will handle pure shell constructs in your script. |
Quote:
Is there a reason you can't use the names you've already mentioned?? Or show us the rest of the script? What is your actual goal, other than this being a 'requirement'? |
Quote:
1) When ran manually by someone by logging into terminal, userx logs into system and do sudo su - edwadm. For this case the command I pasted works perfectly fine and is pulling the O/S user who runs the script (userx in this case). 2) We have a enterprise scheduler where this script is scheduled to run. Scheduler calls the script as local O/S user (edwadm), but scheduler itself run as "root". For this use case I expect osuser to be returned as "root". As root is the user who calls and runs this script as edwadm. However the command I pasted is giving null value. Hope this clarifies your question. |
Quote:
|
All times are GMT -5. The time now is 09:32 AM. |