Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Environmental Variable setting

Status
Not open for further replies.

nithink

Programmer
Nov 7, 2002
92
US
Hi, I would like to set up an environmental variable and use that variable inside a script so that I need not hardcode the path. To do this, I set a variable called 'testpath' in the .login and I tried to do a echo of this testpath inside a script. But it says
testpath: Undefined variable
p.s I tried to put the variable entry in .profile too but no luck.Your help appreciated. Thanks.
 
Hi:

I don't mean to elaborate on the obvious, but did you try exporting it:

export testpath=/somepath

or

testpath=/somepath; export testpath

Regards,

Ed
 
Thanks Ed.

I didnt use export. First I tried using

set testpath = /somepath but it didnt work. Then I tried with

setenv testpath /somepath it worked fine.

Thanks for your suggestion. Does the export command work only in sh & ksh ?

Thanks


 
Yes, you're right. export only works with ksh/sh. I should have picked up you were using csh when you mentioned using .login.

Regards,

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top