Sponsored Content
Top Forums Shell Programming and Scripting how can i past environment variables? Post 302311622 by devtakh on Wednesday 29th of April 2009 07:36:22 AM
Old 04-29-2009
Quote:
Originally Posted by mingming88
how about VARIABLE2, how can i use it??
try this:

Code:
if [ "$ASS1_DATA_DIR" ]; then

    VARIABLE1=$ASS1_DATA_DIR
else
    VARIABLE1=$(pwd)
fi
if [ "$ASS1_OUTPUT_DIR" ]; then

    VARIABLE2=$ASS1_OUTPUT_DIR
else
    VARIABLE2=$(pwd)
fi

or

Code:
VARIABLE1=${ASS1_DATA_DIR:- $(pwd)}
VARIABLE2=${ASS1_OUTPUT_DIR :- $(pwd)}

cheers,
Devaraj Takhellambam
 

10 More Discussions You Might Find Interesting

1. Programming

environment variables

Hi! How-to get the environment variables in GNU. getenv() only fetches the ones that you can find under export (not the ones under declare)... best regars .David (2 Replies)
Discussion started by: Esaia
2 Replies

2. UNIX for Dummies Questions & Answers

environment variables

Hi Folks, Is it possible somehow to unset all the environment variables which have been defined before in UNIX (Solaris). Thanks, Slava (3 Replies)
Discussion started by: spavlov
3 Replies

3. UNIX for Dummies Questions & Answers

help..Environment variables...

hi, 1). i would like to know what is meant by environment variables? 2). is the number of envi variables is a constant number for unix systems? 3). how to see the list of envi variables (and the values of the envi variables)in a single command? 4). if this questions were already asked... (3 Replies)
Discussion started by: sekar sundaram
3 Replies

4. Programming

environment variables

hi, I want to create a new EV(Environment Variable) through a c program and I done this thing through setenv() method. But the newly created EV is not permanent, i.e. when I exit from the program the EV also no longer lives. But I want to make it a permanent EV for the current user. Actually I... (6 Replies)
Discussion started by: sumsin
6 Replies

5. Shell Programming and Scripting

environment variables

Hi, If i have a variable set and exported in my pofile file will that variable be available in all shell scripts created. Thanks, Radhika. (3 Replies)
Discussion started by: radhika03
3 Replies

6. UNIX for Dummies Questions & Answers

Environment variables

why are all environment variables represented in a fixed format regardless of the shell you use? like $HOME $PATH etc (6 Replies)
Discussion started by: sravani
6 Replies

7. Shell Programming and Scripting

Environment variables

I have read tons of posts about how you can't set persisting environment variable in a child script of a shell and have it persist. The only way is to source a file as % . <scriptname> I am finding that true... but I know there is a way around it. I just don't know how. I worked for 6... (5 Replies)
Discussion started by: rwa25
5 Replies

8. HP-UX

Environment Variables

Hi Experts, Need your help in understanding the commands to setup the environment variables in hp-ux. Beleive need to use either set,setenv or export. I am confused between above three options, when to use which option? On command line, I have tried both set and setenv but couldn't... (1 Reply)
Discussion started by: sai_2507
1 Replies

9. Homework & Coursework Questions

Environment Variables

1. The problem statement: What is the mesg value set for your environment? If it is on, how would you turn off your current session? How would you set it permanently? 3. The attempts at a solution : Read Unix The textbook. 3rd chapter has many things like environment variables and... (5 Replies)
Discussion started by: mahinkhan22
5 Replies

10. HP-UX

Environment Variables

Hi All, I need to understand following three environment variables and their usages in HP Unix. _M_ARENA_OPTS _M_CACHE_OPTS PTHREAD_SCOPE_SYSTEM How does these environment variables influence multi threaded applciation and how do we decide the value of these variables? Is there... (0 Replies)
Discussion started by: angshuman
0 Replies
Sendpage::KeesConf(3pm) 				User Contributed Perl Documentation				   Sendpage::KeesConf(3pm)

NAME
Sendpage::KeesConf - implements a configuration file reader SYNOPSIS
use Sendpage::KeesConf; $config = Sendpage::KeesConf->new(); $config->define("variable", { DEFAULT => "setting" }); $config->file("config.cfg"); $setting=$config->get("variable"); DESCRIPTION
I have borrowed VERY heavily from Andy Wardley's (abw@cre.canon.co.uk) "AppConfig" tool, which can be found on CPAN (http://cpan.perl.org) but I found it not dynamic enough for multi-instance variable defaults. As a result, I wrote this massively trimmed-down version for my use. The following methods are available: $config = Sendpage::KeesConf->new(); The constructor doesn't take an arguement, but it should in the future. $config->forget(); This call will make $config forget about any variables it has loaded. It does NOT forget "define"d variables, just instantiated ones via "file". $config->define($name, $options); This will define a variable by the name of $name. $options can contain: ARGCOUNT What type of variable this should be. Default value is "1". The available types are: 0 Boolean (true/false, yes/no, 1/0) 1 Scalar (any string) 2 List (an array of strings) DEFAULT The default value the variable should have if it is not overridden during the call to "file". The DEFAULT must be the same data type as ARGCOUNT. The default DEFAULT is the string "<unset>". UNSET set this to 1 if you want the default value to be undefined. This is a hack to get around the default DEFAULT. $config->instance_exists($name); This tests to see if there is a section loaded named $name $var=$config->ifset($name); This call will search for the variable named $name. If it is not found, it will return undef. If the value exists, it will return the value. This is a way to call "get" without having a default passed through. $var=$config->exists($name); This call will search for the variable named $name. If it is not found, it will return false. If the value exists, it will return true. This is a way for the user to find out if they will get a "default" on a call to "get". $var=$config->fallbackget($name,$quiet); This call will search for the variable named $name. If it is not found, the section portion will be removed, and retried for a sectionless "get" call. That way, global variables can be overridden by section-specific variables. If "SECTION:Instance@name" does not exist, "name" will be tried. $var=$config->get($name); This call will search for the variable named $name. If it is not found, it will fall back to the default for the section. Sections are explained in more detail later. $config->instances($class); Returns an array of the names of all the variables in the class $class. $config->file('program.cfg'); Loads variables from the named file. Syntax for this file is: [SECTION:INSTANCE] VARIABLE1 = VALUE1 VARIABLE2 = VALUE2 . . . If VARIABLE is an array, VALUE is loaded using commas (,) as the list separator. The variable will be available under the name of the section. For example, to see VALUE2, it would be accessed as: $config->get("SECTION:INSTANCE@VARIABLE2"); Notice, that "=", ":", and "@" are all not allowed in section or variable names. Sections can be defined (and loaded) so that defaults can pass back to a defined section default. For example, lets say that you have several modems, and most of them have different settings. You can define all the modem variables like so: $config->define("modem:baud",{ DEFAULT => 9600 }); $config->define("modem:flowctl",{ DEFAULT => "hardware" }); Then, when you load them, let's say the config file has: [modem:sportster] baud = 115200 [modem:hayes] The baud rate for the sportster will come back as 115200, but the hayes will fall back during a "get" call, and find the default for the modem section: 9600. Both fallback to have "flowctl" as "hardware": # returns specific value 115200 $config->get("modem:sportster@baud"); # returns default value 9600 $config->get("modem:hayes@baud"); # both return default value "hardware" $config->get("modem:sportster@flowctl"); $config->get("modem:hayes@flowctl"); CAVEATS
character limitations As mentioned above, variable names (and section names) cannot have the characters ":", "@", or "=" in them. default defaults There should be a way to pass default defaults into "new". That would be handy, and could eliminate the need for the UNSET option in "define". AUTHOR
Kees Cook <kees@outflux.net> SEE ALSO
perl(1), sendpage(1), Sendpage::KeesLog(3), Sendpage::Modem(3), Sendpage::PagingCentral(3), Sendpage::PageQueue(3), Sendpage::Page(3), Sendpage::Recipient(3), Sendpage::Queue(3) COPYRIGHT
Copyright 2000 Kees Cook. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2008-01-03 Sendpage::KeesConf(3pm)
All times are GMT -4. The time now is 06:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy