0

Inside my Shell Script , i have this line present

RUN_CMD="$JAVA_HOME/bin/java -cp $CLASSPATH  com/mypack/BalanceRunner 

Could anybody please tell me , what is meant by this command RUN_CMD and where can i see this RUN_CMD defined

Thanks for reading

3 Answers 3

3

That's defining an environment variable RUN_CMD (looks like a quote omitted at the end, though). It's shorthand for running that Java command (which defines where to find some classes and then specifies which class to run - BalanceRunner)

The variable is in scope for the current process (a shell, or shell script, most likely). You can see what it's set to by doing:

echo $RUN_CMD

(note: specifics are shell-dependent but the above is true for Bourne shell derivatives certainly)

Sign up to request clarification or add additional context in comments.

1 Comment

use quotes: echo "$RUN_CMD"
1

The line you quote is the assignment.

As Brian said, it's only in scope for the current process.

When you run a script (say with ./<script> or bash <script>), a new shell is created in which the script is executed. As such, once the script finishes and you're returned to the prompt, all the variables assigned in the script will be undefined.

The exception to this is of course if you execute the script in the current shell, say by executing it with . <script> or source <script> (see your shell's manual for more details).

You can experiment with this on the prompt:

$ FOO=bar
$ if [ $FOO ]; then echo "FOO defined"; else echo "FOO undefined"; fi
FOO defined
$ echo $FOO
bar
$ unset FOO
$if [ $FOO ]; then echo "FOO defined"; else echo "FOO undefined"; fi
FOO undefined
$ echo $FOO

$ echo 'FOO=bar' > temp
$ . temp
$ echo $FOO
bar
$ unset FOO
$ bash temp
$ echo $FOO

$        

As for the actual content and purpose of the variable in your script, I think Brian and others answer this excellently.

Comments

0

You set the value of an environment variable. As to the title of your question:

 echo $ENV_VAR_NAME

will print the value of a defined environment variable to the console

1 Comment

I tried echo $RUN_CMD on Putty , it displayed just an empty space .

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.