Interpretation of $variables inside programs run from a script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Interpretation of $variables inside programs run from a script
# 1  
Old 06-09-2011
Interpretation of $variables inside programs run from a script

I am running a shell script that executes a program. Inside this program, variables are also referenced using a dollar symbol, eg. $a, $thething, and the shell script is misinterpreting them as variables relevant to the shell script rather than relevant to the program run from inside the script. I know that's an incoherent explanation, so here is an illustration of the problem:

#***do something that defines the variable "outside"
specialized_program << RUNIT
inside=process_data $outside
print $inside

The problem is that "print $inside" prints an empty string, rather than the result of "process_data". How can I fix this?

# 2  
Old 06-10-2011
Try quoting the values and then print/echo.
inside="process_data ${outside}"
echo $inside # since i have tried with echo only not print command

In case your are referencing value to variable outside from some other file say file2.txt, then you would need to source the file file2.txt in the above script.
# 3  
Old 06-10-2011
Try this,
#***do something that defines the variable "outside"
specialized_program << RUNIT
inside=`process_data $outside`
print $inside

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

2. Shell Programming and Scripting

How to run scripts parallely inside shell script?

Hi , I have 4 scripts example script1,script2,script3,script4 . I have to run script1,script2 and script3 parallely since this 3 scripts dont have dependencies . Once script1,script2 and script3 got completed successfully , I have to trigger script4. Can someone help me on this how to... (10 Replies)
Discussion started by: vinothsekark
10 Replies

3. Shell Programming and Scripting

Run .exe inside shell script

I have to run some shell scripts in Windows using Cygwin. I am able to achieve that using %BASH% --login -i "/cygdrive/d/" , where %BASH% is an environment variable in Windows set to C:\cygwin\bin\bash.exe. I have a created a Cygwin environment variable $EXE_PATH =... (3 Replies)
Discussion started by: HemanthJayasimh
3 Replies

4. Shell Programming and Scripting

Running external programs inside an if then else

Good morning, First time poster. be gentle! :) I do not know coding all that well but I can hack the hell out of example scripts! I just cant wrap my brain around this one. Im trying to run two grep statements in the first IF statement and doing an AND between them. Something is going... (6 Replies)
Discussion started by: mrplow2k69
6 Replies

5. Shell Programming and Scripting

how to access variables in a config file inside a shell script

I'm writing a shell script. I want to put the variables in a separate config files and use those inside my script. e.g. the config file (temp.conf)will have the values like mapping=123 file_name=xyz.txt I want to access these variables in temp.conf(i.e. mapping and file_name) from inside the... (7 Replies)
Discussion started by: badrimohanty
7 Replies

6. Shell Programming and Scripting

how to run shell script inside expect script?

I have the code like this : shell script continues ... .... expect -c" spawn telnet $ip expect "login:" send \"$usrname\r\" expect "Password:" send \"$passwd\r\" expect "*\>" send \"$cmdstr\r\" ... (1 Reply)
Discussion started by: robbiezr
1 Replies

7. Shell Programming and Scripting

Run the command inside perl script

I have a command which will run fine in a unix command prompt. Can you tell how to interprete this command inside perl script...... The command is : perl -pe 's/(\|333\}.*)\}$/$1|1.6}/' FIA.txt This will search for the number 333 and appends 1.6 at the end of that line....... (1 Reply)
Discussion started by: vinay123
1 Replies

8. Solaris

How to run a script as different user inside cronjob in solaris.

Hi , I have a shell script to perform some actions on sun solaris box . This script normally requires to be run as a different user. so, whenever i have to run this script, i need to sudo in as that user , enter the password and execute it. Now,I have to setup a cronjob to execute the script... (11 Replies)
Discussion started by: csg_user
11 Replies

9. Shell Programming and Scripting

How to run an SQL script inside a shell

How do I create a K Shell which would silently (without user input) logon to Oracle and run an SQL script? Any help will be greatly appreciated. Steve (1 Reply)
Discussion started by: stevefox
1 Replies

10. Shell Programming and Scripting

passing variables to sed inside script

I am trying to pass a regular expression variable from a simple script to sed to remove entries from a text file e.g. a='aaaa bbbb cccc ...|...:' then executing sed from the script sed s'/"'$a"'//g <$FILE > $FILE"_"1 my output file is always the same as the input file !! any... (5 Replies)
Discussion started by: Daniel234
5 Replies
Login or Register to Ask a Question