We currently use pbrun to switch user and then run our commands.
For ex.
$ pbrun /bin/su - enterprisedb
Last login: Wed Nov 10 15:44:43 MST 2021 on pts/5
[enterprisedb@server_name ~]$ whoami
enterprisedb
[enterprisedb@server_name ~]$
Below is how my pbrun policy is defined.
[ RunAs User ] [ Command ]
root /bin/su - enterprisedb
How can I script it? I want to run a command (for ex. whoami) using enterprisedb user from my current user(ADS) on that server.