Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Using Variables to Set Other Variables Post 69836 by superdelic on Wednesday 20th of April 2005 04:10:57 PM
Old 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

how to set up linux environment variables?

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

Where are Oracle variables set in Solaris 5.9

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

How to set permanent variables

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

SET Command removed the variables

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

Help finding where certain environment variables are set

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

Problems with expect and set variables

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

Need to SET Environment variables

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

Set variables from file, then loop

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

How to set a variable name from another variables value?

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

Set env variables for user

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
Perl::Critic::Policy::Variables::ProhibitUnusedVariablesUser)Contributed Perl DocumenPerl::Critic::Policy::Variables::ProhibitUnusedVariables(3pm)

NAME
Perl::Critic::Policy::Variables::ProhibitUnusedVariables - Don't ask for storage you don't need. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
Unused variables clutter code and require the reader to do mental bookkeeping to figure out if the variable is actually used or not. At present, this Policy is very limited in order to ensure that there aren't any false positives. Hopefully, this will become more sophisticated soon. Right now, this only looks for simply declared, uninitialized lexical variables. my $x; # not ok, assuming no other appearances. my @y = (); # ok, not handled yet. our $z; # ok, global. local $w; # ok, global. This module is very dumb: it does no scoping detection, i.e. if the same variable name is used in two different locations, even if they aren't the same variable, this Policy won't complain. Have to start somewhere. CONFIGURATION
This Policy is not configurable except for the standard options. AUTHOR
Elliot Shank "<perl@galumph.com>" COPYRIGHT
Copyright (c) 2008-2011 Elliot Shank. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.14.2 2012-06-07 Perl::Critic::Policy::Variables::ProhibitUnusedVariables(3pm)
All times are GMT -4. The time now is 06:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy