My agent is install as user js7 on a server.
this user is allowed in sudoers to sudo without asking a password
made a test job with this script
#!/bin/bash
whoami
sudosu-anotherone
whoami
exit
result should be
js7
anotherone
but, after running the result is
js7
js7
commadn sudo su seems to execute fine, but did not changed user.
how can i tell my shell to go to different user in order to executer shell owned by this user ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yeah figure this out later i could do this, fogot the EOF kind of way
as i'm only lauching already existing ksh script, i did a sudo su - <user> -c "/path/to/script.ksh"
and it works fine as well
thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
My agent is install as user js7 on a server.
this user is allowed in sudoers to sudo without asking a password
made a test job with this script
result should be
js7
anotherone
but, after running the result is
js7
js7
commadn sudo su seems to execute fine, but did not changed user.
how can i tell my shell to go to different user in order to executer shell owned by this user ?
Hi Chico,
sudo works for a single command when used in scripts. This is a shell limitation and is not related to JS7.
Your job script should use multiline input like this:
A practical approach is use of JS7 - Script Includes to hide sudo commands from job scripts:
The sudo-begin Script Include holds the line:
sudo -su anotherone <<EOFThe sudo-end Script Include holds the line:
EOFYeah figure this out later i could do this, fogot the EOF kind of way
as i'm only lauching already existing ksh script, i did a
sudo su - <user> -c "/path/to/script.ksh"and it works fine as well
thanks.