Computing.Net > Forums > Unix > Variables in Shell SCripting

Variables in Shell SCripting

Reply to Message Icon

Original Message
Name: pmjain
Date: February 26, 2004 at 22:14:10 Pacific
Subject: Variables in Shell SCripting
OS: UNIX/Window
CPU/Ram: ----
Comment:

Shell Scripting -- Variables
In the main script i have exported the variable and accessing it in another file
but when i echo the value the value of the exported variable is not viewable .
below are the scripts . can anyone let me know whats wrong with the following script

main script looks like
----
. ./functions.sh
export SCRIPT_NAME
SCRIPT_NAME=testing.sh
----
functions.sh looks like as below
----
OUTPUT_DIR=/export/shalini/
OUTPUT_FILE=$SCRIPT_NAME
OUTPUT=${OUTPUT_DIR}/${OUTPUT_FILE}

echo $OUTPUT
echo $SCRIPT_NAME
start_time()
{
//function detials
}


Report Offensive Message For Removal


Response Number 1
Name: aigles
Date: February 27, 2004 at 01:33:32 Pacific
Subject: Variables in Shell SCripting
Reply: (edit)

The variable SCRIPT_NAME is not yet set when you try to use it in 'function.sh' (you define it after sourcing 'function.sh'.

Main script:
----
export SCRIPT_NAME=testing.sh
. ./functions.sh


Jean-Pierre.


Report Offensive Follow Up For Removal

Response Number 2
Name: pmjain
Date: February 27, 2004 at 01:40:41 Pacific
Subject: Variables in Shell SCripting
Reply: (edit)

Thanks a lot for your help Jean-Pierre


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Variables in Shell SCripting

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge