2

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? enter image description here

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 -

7
  • 1
    sw? What's this command supposed to do? Aren't you trying to use su? Commented Feb 24, 2014 at 15:06
  • tbh i dont know why, but it changes the user (see the update) Commented Feb 24, 2014 at 15:09
  • 1
    sw almost certainly starts a new interactive shell, so the next command in the sequence would not run until that shell exits. Commented Feb 24, 2014 at 15:20
  • may be sw is an alias or softlink to su. what does "ls -l which su" output say? Commented Feb 24, 2014 at 15:20
  • Sorry, didnt quite get what needs to be typed into bash from your last comment Commented Feb 24, 2014 at 15:22

3 Answers 3

5

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"

Sign up to request clarification or add additional context in comments.

2 Comments

bash-3.2$ sw upstream_mdm -c "date;ls;" --> Sorry, user ehwe is not allowed to execute '/bin/su - upstream_mdm -c date;ls;' as root on server_name
guess it is a permissions issue -_-
0

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.

2 Comments

bash: alias: sw: not found
If you try which sw, then ls -l that file?
0

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

2 Comments

is there a way to run this echo command under the user_name user ?
See @chidori's answer, if sw is anything like su.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.