The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to use substr to return data into a shell script variable? ttunell Shell Programming and Scripting 3 07-23-2008 12:02 AM
Setting environment variable on a remote solaris machine using shell script eamani_sun Shell Programming and Scripting 1 05-30-2008 10:05 PM
The Lightweight X11 Desktop Environment: A return to basics iBot UNIX and Linux RSS News 0 12-04-2007 12:30 PM
Set the 'DISPLAY' environment variable script orno Shell Programming and Scripting 3 02-12-2007 12:27 PM
problem in getting the path of environment variable set in bashrc in my shell script krithika Shell Programming and Scripting 8 05-26-2006 08:19 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-17-2009
bce_groups bce_groups is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 7
Simple script to return environment variable

HI ,


In the below script I am trying to return the value of the environment variable TIBCO_HOME to the caller

#! /usr/bin/csh
set VAR_NAME=$1
echo VAR_NAME


On the aix console.. set to setenv TIBCO_HOME /app/tibco

When I execute the script… myscript.sh TIBCO_HOME, the script prints TIBCO_HOME. But I am expecting /app/tibco.

Can anyone help me to fix this?


Thanks,

Babu
  #2 (permalink)  
Old 03-17-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
Code:
#! /usr/bin/csh
set VAR_NAME=$1
echo $VAR_NAME
  #3 (permalink)  
Old 03-17-2009
bce_groups bce_groups is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 7
HI,
Thanks for your response.
I changed my script but still the script prints TIBCO_HOME.

I am invoking the script as "csh -f test1.sh TIBCO_HOME"

echo $TIBCO_HOME on unix console returns /app/tibco, I want the same output from my script.

Below is the modified script..

#! /usr/bin/csh
set VAR_NAME=$1
echo $VAR_NAME

Thanks,
bce
  #4 (permalink)  
Old 03-18-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,382
try to source the script
  #5 (permalink)  
Old 03-18-2009
rikxik's Avatar
rikxik rikxik is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 250
It is doing what its expected to do. You need to do this:

Code:
#! /usr/bin/csh
set VAR_NAME=$1
eval echo \$$VAR_NAME
  #6 (permalink)  
Old 03-18-2009
bce_groups bce_groups is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 7
Thanks u so much. I am getting the result.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0