usage of same variable in multiple scripts


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers usage of same variable in multiple scripts
# 1  
Old 07-01-2008
usage of same variable in multiple scripts

Hi,

I have a .test file which has:
#!/bin/ksh
export TEST_FLAG=1

In the test1.ksh i have:
#!/bin/ksh
. .test
echo $TEST_FLAG

When i execute the test1.ksh its showing the value as 1.
But if i refer the same variable in another script, the value is not 1.

Basically, I need to have a flag. The flag will be set in the first script. And based on that value, i need to so some operations in my second script. Can any body help me for this ... please
# 2  
Old 07-01-2008
How are you running test.ksh? If you source it that should be OK. If you are starting up a new shell that will not work and you will have to do something else. You might pass the flag using a temporary file.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Multiple Users - Multiple Scripts

Hello All, I have to restart 100's of scripts for at least 20+ users once the server restarts for any reason. I wanted to come up with a single script to trigger of all scripts/programs under all users with just one script (without root privilege). Is it possible to do so? :confused: If not,... (6 Replies)
Discussion started by: PikK45
6 Replies

2. Shell Programming and Scripting

Cpu and memory usage scripts

All I am writing a script to generate an email when cpu and memory usage is high for 5 min continuously help me urgent I wrote below scritpt LOAD=75.00 CPU_LOAD= 'sar -P all 300 5 |grep 'Average.all* '| awk -F " " '(print 100.0 -$NF)'' IF }; ECHO "pLEASE CHECK YOUR PROCESS ON YOUR... (1 Reply)
Discussion started by: anil529
1 Replies

3. Shell Programming and Scripting

How to create a variable without multiple concats in a perl scripts that makes a bsub?

The red text at the bottom represents the three lines I want to address. I'm dynamically creating a bsub with a perl script and would like to create the fasta_16S variable in a single line....not three. I'm having difficulty in getting the syntax correct. Obviously, there is some confusion... (3 Replies)
Discussion started by: jdilts
3 Replies

4. Shell Programming and Scripting

Calling multiple scripts from another scripts

Dear all, I am working on script which call other shell scripts in a loop but problem is from second script am not able to come out. Here is the snippet:- #!/bin/bash HSFILE=/root/Test/Components.txt LOGFile=/opt/domain/AdminDomain/application/logs... (3 Replies)
Discussion started by: sharsour
3 Replies

5. Shell Programming and Scripting

Detail on For loop for multiple file input and bash variable usage

Dear mentors, I just need little explanation regarding for loop to give input to awk script for file in `ls *.txt |sort -t"_" -k2n,2`; do awk script $file done which sorts file in order, and will input one after another file in order to awk script suppose if I have to input 2 or... (4 Replies)
Discussion started by: Akshay Hegde
4 Replies

6. Shell Programming and Scripting

Change Variable Value from Multiple Scripts and Use these Variable

Hi to All, Please find below details. file_config.config export file1_status="SUCCESS" export file2_status="SUCCESS" file_one.sh I am calling another two shell script from these script. I need to pass individual two script status (If it's "FAILED") to file_main.sh. file_main.sh I... (2 Replies)
Discussion started by: div_Neev
2 Replies

7. Shell Programming and Scripting

Confused with the usage of one variable usage

Hi All I am not able to understand the usage of d# in the below variable declaration. FILE_LOC contains the directory path And also help me to know about what will be saved in the variable j. Thanks!!! j=${d#${FILE_LOC}/} (2 Replies)
Discussion started by: mohanm
2 Replies

8. Shell Programming and Scripting

shc usage with octave scripts - HOW ????

Hello there. I would like to know how to use shc (the generic shell script compiler ) with octave scripts. With sh scripts it works fine (because it automatically recognizes the interpreter - here bash ). But when use with octave scripts like this easy one #! /usr/bin/octave disp("testing...")... (0 Replies)
Discussion started by: spiriad
0 Replies

9. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

10. Shell Programming and Scripting

Manipulating a variable across multiple shell scripts

I have a shell script similar to: #!/bin/sh a=1 source a1.sh -- Modifies a source a2.sh -- Modifies a echo "After execution, value of a is $a" What i need is a1.sh script modify the same variable a and same with a2.sh. Now the echo "After execution, value of a is $a" should print the... (1 Reply)
Discussion started by: indianjassi
1 Replies
Login or Register to Ask a Question