On Tue, 10 Jun 2003, Chris Staskewicz wrote:

> We use an in-house Unix function called "be" which allows one to change
> their user identity to something else.  For example, "user% be project"
> typed at the command-line in a shell will change my user identity to
> "project%" which will then allow me to "cd" to the project directory,
> read, write, and so on.  When I type "project% exit", my command prompt
> is changed back to "user%".

So, it does much what the `su` command does, yes? By default su asks for
Super-User priviliges, but if you give an account name (exactly what
you're saying you do with `be`) then you can Switch to that User. What can
the `be` commad do that `su` can't, out of curiosity?

Anyway, it may seem more baroque than what you have in mind, but one
approach would be to run the sequence of commands via ssh to localhost for
that alternate user. The two nice things here off the bat are that [a] you
shouldn't hit that problem with exiting the shell, and [b] you can set up
ssh-agent to allow controlled access to password-protected accounts,
rather than leaving any passwords in the clear in your script.

One way to go about this might be something like this:

  foreach $project @projects {

      &do_stuff();

      $commands = determine_conversions();

      system( "ssh", "[EMAIL PROTECTED]", "$commands" );

  }

Or something like that. You can replicate the important bit from the
command line: calling ssh with a list of commands will run those commands
and then exit, so the problem of figuring out how to escape falls out of
the equation here.

Tim Toady and all that :)



-- 
Chris Devers    [EMAIL PROTECTED]

trademark, n.
A legally protective operator serving to distinguish, say, Hoover the
generic vacuum cleaner from Hoover a particular deceased, Red-baiting,
transvestite head of the FBI. See also COPYLEFT; COPYRIGHT;
INTELLECTUAL PROPERTY; PATENT; WEASEL.

    -- from _The Computer Contradictionary_, Stan Kelly-Bootle, 1995
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to