[SunHELP] Shell Problem
Naresh Narang
sunhelp at sunhelp.org
Mon Apr 16 23:28:58 CDT 2001
Hi Nicholas,
I am stuck with having to set a library path used by different users
using different shells like sh, csh, tcsh etc. and they have different
syntex. Yes, they'll have to source it. There is no common syntex when it
comes to sh and csh. I think I'll need to create two separate scripts; one
for users using sh, bash, ksh and one for users using csh, tcsh.
Thanks,
Naresh
----- Original Message -----
From: "Nicholas Dronen" <ndronen at frii.com>
To: <sunhelp at sunhelp.org>
Sent: Monday, April 16, 2001 6:28 PM
Subject: Re: [SunHELP] Shell Problem
> The Bourne and Korn shells set $SHELL. The C shell sets $shell.
> But perhaps we're getting ahead of ourselves. What are you
> trying to do, really? I think I know, but you don't say
> exactly.
>
> If you want to change a user's environment from within a shell
> script such that the environment will remain changed after
> the script "exits," you *must* have the user source the file
> so it's run in the current shell.
>
> Bourne and Korn shell syntax:
>
> $ . [ file ]
>
> C shell syntax
>
> % source [ file ]
>
> I think this covers the first part of your confusion. The second
> part is this: since Bourne/Korn and the C shell use different syntax
> for setting environment variables, you need to know which shell
> the user is using in order to know which syntax to use, but in order
> to know which shell the user is using, you need to use either Bourne/Korn
> shell or C shell syntax to check the SHELL or shell environment variables
> (which isn't actually reliable anyway) or to run a command or whatever,
> so you're pretty much stuck.
>
> And you are stuck.
>
> What you *should* do is require that the user *source* a shell script
> that is named so they can tell which one is intended for them, say,
> a C shell user. "Hi. I use the C shell. I source foo.csh in order
> to set environment variables for application X."
>
> Mind you, this is just a guess.
>
> If the values of the environment variables do not need to survive
> the execution of the script, then just call the script! :)
>
> Regards,
>
> Nicholas Dronen
>
> On Mon, Apr 16, 2001 at 05:23:31PM -0700, Naresh Narang wrote:
> > Hi
> >
> > I want to set up env. variables based upon the shell a user is
running, so in order to find what shell a user is using, I have to run a
script in a Shell say /bin/sh. If I run it using #!/bin/sh to find user's
shell, every shell behaves differently or if I use other methods to find
shell then how do I use that shell to set env variable that can be read by
user's shell and other statements are ignored.
> >
> > Basically I want a general script that can set env variables based on
user's shell syntex.
> >
> > Any help is appreciated.
> >
> > Thanks
> > Naresh
> >
> > -- Naresh
> > ______________________________________________________
> > 123India.com - India's Premier Portal
> > Get your Free Email Account at http://www.123india.com
> >
> >
> > _______________________________________________
> > SunHELP maillist - SunHELP at sunhelp.org
> > http://www.sunhelp.org/mailman/listinfo/sunhelp
> _______________________________________________
> SunHELP maillist - SunHELP at sunhelp.org
> http://www.sunhelp.org/mailman/listinfo/sunhelp
>
NetZero Platinum
No Banner Ads and Unlimited Access
Sign Up Today - Only $9.95 per month!
http://www.netzero.net
More information about the SunHELP
mailing list