manipulate path variable in a shell script?

This is a discussion on manipulate path variable in a shell script? within the shell forums in Operating Systems category; Hi, I wanna add a element to my $PATH and remove it later on. So I think I can write two shell script to do the adding and removing, but you know, any export statement executed in a shell script will take no effect on current shell. So my script will not be of use. So, how do I do? Thanks. - woody...

Go Back   Database Forum > Operating Systems > shell

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-28-2008, 12:36 AM
Default manipulate path variable in a shell script?

Hi,

I wanna add a element to my $PATH and remove it later on. So I think
I can write two shell script to do the adding and removing, but you
know, any "export" statement executed in a shell script will take no
effect on current shell. So my script will not be of use. So, how do
I do?

Thanks.

-
woody
Reply With Quote
  #2  
Old 08-28-2008, 02:10 AM
Default Re: manipulate path variable in a shell script?

* Steven Woody :
> Hi,
>
> I wanna add a element to my $PATH and remove it later on. So I think
> I can write two shell script to do the adding and removing, but you
> know, any "export" statement executed in a shell script will take no
> effect on current shell. So my script will not be of use. So, how do
> I do?


Source your scripts in the current shell using the '.' command.
For example:

$ . add2path

> Thanks.
>
> -
> woody


--
James Michael Fultz
Remove this part when replying ^^^^^^^^
Reply With Quote
  #3  
Old 08-28-2008, 02:20 AM
Default Re: manipulate path variable in a shell script?

On Aug 28, 1:10 pm, James Michael Fultz wrote:
> * Steven Woody :
>
> > Hi,

>
> > I wanna add a element to my $PATH and remove it later on. So I think
> > I can write two shell script to do the adding and removing, but you
> > know, any "export" statement executed in a shell script will take no
> > effect on current shell. So my script will not be of use. So, how do
> > I do?

>
> Source your scripts in the current shell using the '.' command.
> For example:
>
> $ . add2path
>
> > Thanks.

>
> > -
> > woody

>
> --
> James Michael Fultz
> Remove this part when replying ^^^^^^^^


Thank you.
Reply With Quote
  #4  
Old 08-31-2008, 02:26 AM
Default Re: manipulate path variable in a shell script?

On Aug 27, 10:20 pm, Steven Woody wrote:
> On Aug 28, 1:10 pm, James Michael Fultz wrote:
> > * Steven Woody :
> > > I wanna add a element to my $PATH and remove it later on. So I think
> > > I can write two shell script to do the adding and removing, but you
> > > know, any "export" statement executed in a shell script will take no
> > > effect on current shell. So my script will not be of use. So, how do
> > > I do?

> > Source your scripts in the current shell using the '.' command.
> > For example:
> > $ . add2path

Or have the script/program write shell commands as output, and use
eval,
e.g.:
eval `my_program`
Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 12:34 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by bbpixel2008 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.