su in a script?

Michael O'Donnell mod at std.com
Wed Dec 8 14:30:07 EST 1999




su causes the spawning of a subordinate shell, which can't see
the contents of your script.  You can demonstrate like this:

    su someOtherUser
    echo OK - su is finished

You'll see the echo when you terminate someOtherUser's session.



If you really want folks to run as some other user
and they always do the same thing while that other
user's guise, then you can just modify that other
user's startup scripts (e.g.  their .bash_profile)
so you could invent some user named playQuake and
cause playQuake's .bash_profile to always start Quake.

Then you could use the "-" argument to su to force
execution of the login script, thus:

    su - playQuake

Of course, I have no idea what you're really trying
to accomplish, so this might all be dramatic overkill...

-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).



More information about the Discuss mailing list