04-20-2005
Using Variables to Set Other Variables
I have a script that I'm trying to shorten (below) by removing repetitive code.
if [[ -a ${abccontrols}/Commodity_NDM_${alt_db}_done ]]
then
commodity_ndm_done=Y
fi
if [[ -a ${abccontrols}/Customer_NDM_${alt_db}_done ]]
then
customer_ndm_done=Y
fi
if [[ -a ${abccontrols}/Department_NDM_${alt_db}_done ]]
then
department_ndm_done=Y
fi
if [[ -a ${abccontrols}/Division_NDM_${alt_db}_done ]]
then
division_ndm_done=Y
fi
if [[ -a ${abccontrols}/Order_Detail_NDM_${alt_db}_done ]]
then
order_detail_ndm_done=Y
fi
if [[ -a ${abccontrols}/Order_Summary_NDM_${alt_db}_done ]]
then
order_summary_ndm_done=Y
fi
if [[ -a ${abccontrols}/Witron_Forward_Pick_NDM_${alt_db}_done ]]
then
witron_forward_pick_ndm_done=Y
fi
And I tried using a loop as such:
{
echo "Commodity"
echo "Customer"
echo "Department"
echo "Division"
echo "Order_Detail"
echo "Order_Summary"
echo "Witron_Forward_Pick"
} |
while read v_type
do
if [[ -a ${abccontrols}/${v_type}_NDM_${alt_db}_done ]]
then
$(echo ${v_type} | tr '[A-Z]' '[a-z]')_ndm_done=Y
fi
done
Naturally, it doesn't work. Can I make variables set other variables by this method or another?
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi
I'm using Linux, in the directory /root/my
there is a.out. but when I try to run it , the
shell indicate "bash:a.out: command not found"
but I AM working in this directory. if I use
"./a.out" , it works perfectly.
can any body tell me how to do a permanent set up so that
I can use... (5 Replies)
Discussion started by: dell9
5 Replies
2. UNIX for Dummies Questions & Answers
Hi,
It is solaris 5.9, and Oracle 10G is the database. If i login as user, and give 'env' command i can see the Oracle environment variables are set.
PATH=/usr/bin:/usr/sbin:/usr/lib:/etc/ssh:/opt/oracle/app/oracle/product/10.2.0/db_1/bin:/opt/oracle/crs/oracle/product/10.2.0/crs_1/bin... (1 Reply)
Discussion started by: scriptlearner
1 Replies
3. AIX
I set my TERM variable to work with SMIT and everything works fine but when I logged out and log in again I have to set the variable again.
How can I set a permanent variable into the system so it will be as I wish even if a reboot is needed?
I set variables this way:
export VAR=value (7 Replies)
Discussion started by: agasamapetilon
7 Replies
4. UNIX for Dummies Questions & Answers
Hi,
Im using csh and sometimes bash.
I accidentally typed SET and looks like it has resetted some enviroment variables as im not able to run autosys jobs etc ..
So i wanted to know how i can put it back to normal by replacing any profile files from another user or by editing the file which... (2 Replies)
Discussion started by: spectator
2 Replies
5. SCO
i have two machines that should be identical but on one system there are some oracle environment (ORACLE_SID, ORACLE_HOME, etc...) variables that are not being set for the users.
I am trying to find where those environment variables are being set on the system which is working properly. All... (5 Replies)
Discussion started by: kuliksco
5 Replies
6. Shell Programming and Scripting
I'm writing a script that'll send a time-stamp to my backup server. I create a file with the name of the current date, send it to my server with scp and rm the file from the local computer.
Individually these commands work fine and with a set name the expect scripts also work fine. The problem... (0 Replies)
Discussion started by: Ktesh564
0 Replies
7. Shell Programming and Scripting
Hi
Could you please tell me how to set environment variables in Unix ksh.
And how can acess those varibles in shell scripts
( Please give the code with an example)
For my scenario.
We have written number of shell scripts with hard coded username and password.
But if we want to... (1 Reply)
Discussion started by: shyamu544
1 Replies
8. Shell Programming and Scripting
Hello,
I am very, very new to shell scripting, but what I'm attempting to do is read in a list of user ID's to create on a database system from a CSV flat file, and for each entry run the "create user" script. I've gotten pretty far but I'm having trouble with the looping mechanism.... Any... (8 Replies)
Discussion started by: jkarren
8 Replies
9. Shell Programming and Scripting
Experts,
I want to set value of variables like this in bash shell:
i=5 ; L=100
I want variable d5 (that is d(i) ) to be assign the value of $L ,
d$i=$L ; echo $d5
Not working
Thanks., (3 Replies)
Discussion started by: rveri
3 Replies
10. UNIX for Dummies Questions & Answers
Hi ,
I have installed oracle in Solaris machine and unable to set the env variable. I tried to put the env variable in .dtprofile file but didn't help. So everytime I login in need to run the command and export the variable. Kindly suggest where I am doing wrong.Pls excuse as I am not too... (2 Replies)
Discussion started by: Rossdba
2 Replies
LEARN ABOUT PHP
parse_str
PARSE_STR(3) 1 PARSE_STR(3)
parse_str - Parses the string into variables
SYNOPSIS
void parse_str (string $str, [array &$arr])
DESCRIPTION
Parses $str as if it were the query string passed via a URL and sets variables in the current scope.
Note
To get the current QUERY_STRING, you may use the variable $_SERVER['QUERY_STRING']. Also, you may want to read the section on vari-
ables from external sources.
Note
The magic_quotes_gpc setting affects the output of this function, as parse_str(3) uses the same mechanism that PHP uses to populate
the $_GET, $_POST, etc. variables.
PARAMETERS
o $str
- The input string.
o $arr
- If the second parameter $arr is present, variables are stored in this variable as array elements instead.
RETURN VALUES
No value is returned.
EXAMPLES
Example #1
Using parse_str(3)
<?php
$str = "first=value&arr[]=foo+bar&arr[]=baz";
parse_str($str);
echo $first; // value
echo $arr[0]; // foo bar
echo $arr[1]; // baz
parse_str($str, $output);
echo $output['first']; // value
echo $output['arr'][0]; // foo bar
echo $output['arr'][1]; // baz
?>
SEE ALSO
parse_url(3), pathinfo(3), http_build_query(3), get_magic_quotes_gpc(3), urldecode(3).
PHP Documentation Group PARSE_STR(3)