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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export CShell Variable?

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

In Bourne shell scripts I use the export command to ensure the value of a variable remains available after the script ends.

In the below script that value for my DISPLAY variable is not retained in my C-Shell environment after my script ends.

Code:
/bin/echo "Enter hostname or IP to redirect DISPLAY to: \c"
set REMOTE_HOST=(`line`)

setenv DISPLAY {$REMOTE_HOST}:0
/bin/echo "$DISPLAY" [COLOR=green]<=== This displays correctly[/color]

1. Does C-Shell variables require an export type command too? If yes, what is it?
2. What can you recommend to retain the value of my DISPLAY variable after my C-Shell script has ended?

Thanks,

Michael
 
Michael,

I can't believe that the value of a variable remains available after the script ends, neither in Bourne nor C shell.

I suppose what you do is to source that script;
In Bourne shell this means:
. my_defs

The C shell equivalent is:
source my_defs

hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top