Answer the question
In order to leave comments, you need to log in
How to run a bash script passing a parameter at startup?
I'm not sure how clear I expressed the problem in the title .., but you need to run the script as follows ./skript.sh user
Where user is the value of the variable that determines which user will run some script commands.
And since it must be run from cron - read, not an option. whoami - too, because users are different.
Can you please tell me if this is possible at all, and if so, how? Thank you.
Answer the question
In order to leave comments, you need to log in
If you need to separate commands (one from one user, others from another), then you can use sudo inside the script.
Script
#!/bin/bash
user=${1:-guest}
whoami
sudo -u "$user" whoami
exit 0
[[email protected] sh]$ ./t.sh guest
guest
guest
[[email protected] sh]$ ./t.sh apache
guest
apache
[[email protected] sh]$
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question