Reputation: 4557
The problem:
Number of the commands must be executed consequently, written in one-line command:
comamand1; command2; command3;
The very first command is
sw user_name;
The problem is that no commands are executed after the sw user_name; one. (the user gets changed though)
Any ideas about how i can execute the string of the commands described above?
P.S.
bash-3.2$ sw
Sorry, user ehwe is not allowed to execute '/bin/su -' as root on server_name
Guess it explains what the sw is :)
P.P.S sw stands for /bin/su -
Upvotes: 2
Views: 2360
Reputation: 530970
You cannot change the user of a given process; you can only start a new process running as the new user. As such, sw
is probably starting a new interactive shell. When that shell exits, the sw
command completes, and the next command in your sequence can complete. For example:
$ sw user_name; echo "Second command executes"
$ echo hello
hello
$ exit
Second command executes
Upvotes: 0
Reputation: 150
It sounds to me like sw
might be some sort of alias to su
. You can check with alias sw
. If this is the case, you could probably use chidori's answer, just replace su
with sw
.
Upvotes: 0
Reputation: 1112
Hoping that you meant "su" and not "sw" . If you wanted to switch as some user and execute set of commands probably you can use -c option. you can try something like this su - chidori -c "date;ls;df"
Upvotes: 5