Passing commands to subshell

Passing commands to subshell

Post by mrblasbe6.. » Sun, 11 Feb 2001 00:44:52



Can someone give me an example of how to execute commands as a different user
and then other commands as root through a single script.

I was trying something like:

su - diffUser
...execute command as diffuser
...somehow exit subshell
...
then su to another user and execute commands
and finally return to parent shell and finish script.

I was trying to get all of these commands in a single script for easy
maintenance.

Sent via Deja.com
http://www.deja.com/

 
 
 

Passing commands to subshell

Post by Bill Marcu » Sun, 11 Feb 2001 02:03:18



>Can someone give me an example of how to execute commands as a different
user
>and then other commands as root through a single script.

>I was trying something like:

>su - diffUser
>...execute command as diffuser
>...somehow exit subshell
>...
>then su to another user and execute commands

su - diffUser << endSU
  command
  command
  ...
endSU

 
 
 

Passing commands to subshell

Post by freema.. » Sun, 11 Feb 2001 02:19:17




> Can someone give me an example of how to execute commands as a
different user
> and then other commands as root through a single script.

> I was trying something like:

> su - diffUser
> ...execute command as diffuser
> ...somehow exit subshell
> ...
> then su to another user and execute commands
> and finally return to parent shell and finish script.

> I was trying to get all of these commands in a single script for easy
> maintenance.

I have seen the remsh command back to the same host machine as a way to
simulate this.

You will have to set up the .rhosts files or the host.equivalent file to
allow permissions.

Say your unix box is named dino.

then, you would remsh dino -l user1 scriptname
scriptname would then operate

Sent via Deja.com
http://www.deja.com/

 
 
 

1. How to pass an argument to subshell of bash?

   I have an alias in csh:

alias ed "emacs \!* &"

it allows me to start emacs in the background using

ed myfile

I'm trying to write an alias for bash and can't:

alias ed="emacs \!* &"
It doesn't work properly: I can't pass argument (file name) to the subshell
where emacs is executed in that case.
Does anyone know how to fight the problem?
Thanks in advance, Vladimir

2. "Tar-Baby": Data read/write dilemma using "tar"

3. Passing information from a subshell to its parent

4. APM save to disk problem

5. pass array value to subshell ?

6. Soundcard problems

7. Cygwin:Bash: Preserve '\' in cmdline arg to pass to subshell?

8. Gnome Task Bar

9. `Nested (`Nested Subshells`) Subshells`

10. tcsh - to subshell or not to subshell

11. How can I pass a command line argument to an aliased command?

12. bash redirection stdout and stderr - pipeline command causes subshell execution

13. getting status from a subshell command in a pipe-line