Sponsored Content
Top Forums Shell Programming and Scripting Set Environment variable from another file Post 302450244 by rsivasan on Thursday 2nd of September 2010 04:21:22 AM
Old 09-02-2010
how to create config_file.

vi mode is acceptable for crating config file.

like....vi config_file
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How does the PATH and MANPATH environment variable get set?

Hi, How does the PATH and MANPATH environment variable get set? I want to add "/opt/SUNWspro/bin" to the search path for all the users. Where can I access this variable. I know in my home directory, depend on which shell I use, there are files such as .profile and .cshrc which I can edit to... (3 Replies)
Discussion started by: vtran4270
3 Replies

2. UNIX for Advanced & Expert Users

set environment variable?

Installed a program, need to set the system up so that when the executable is entered, it finds the path to the executable. In Windows, set under system properties, advanced, environmental variables. How do I do this with Unix? Specifically using Solaris 9. I have tried: env... (3 Replies)
Discussion started by: kohoutek
3 Replies

3. UNIX for Advanced & Expert Users

how to set the environment variable at run time

hi, I have one environment variable like path in my system.But in my program i need to change that path .suppose it has a value "config" now i need to chage it as "config1" or something else.i need to use that variable for complete project.It means at first it will use the old path but after... (4 Replies)
Discussion started by: sada@123
4 Replies

4. Shell Programming and Scripting

problem in getting the path of environment variable set in bashrc in my shell script

hi all i have joined new to the group. i have set an variable in my bashrc file. .bashrc PROGHOME=/home/braf/braf/prog export PROGHOME but while using it in my shell script its path is not taken and i had to explicitly give the export command to set the path. in my script... (8 Replies)
Discussion started by: krithika
8 Replies

5. Linux

How do i set environment variable

Hi, I am quite new to Linux. And I have doubt how to set new environment variable with value to a C executable. Let say I have a environment variable $Hack ; I would like to load a value for this variable; so that when the C executable is executed, the $Hack would set the variable value. ... (4 Replies)
Discussion started by: ahjiefreak
4 Replies

6. Solaris

set environment variable?

I am working with solaris 9 sunBlade150 Box. I Installed a program, need to set the environment variable so that when the executable is entered,it finds the path to the executable. The documentation for the software says: Set the appropriate environment variable: Connect to server failed;... (8 Replies)
Discussion started by: smartgupta
8 Replies

7. UNIX for Dummies Questions & Answers

ORACLE_HOME environment variable not set!

hi, i am new to perl: os : Linux i wrote simple perl script to select from table i am getting this error and how to set ORACLE_HOME environment variable : script: #!usr/bin/perl use DBI; use Mail::Sendmail; #use Date::Calc; use MIME::QuotedPrint; use HTML::Entities; use POSIX... (2 Replies)
Discussion started by: prakash.gr
2 Replies

8. Shell Programming and Scripting

Setting Environment variable from value in file

I've searched Google and now this forum. Best guess is my search fu is not good (and it probably isn't). The Google search did bring me here. Background I have a number of Korn Shell scripts who all use one of 3 values for an environment variable used in the backup system. On occasion one or... (8 Replies)
Discussion started by: WolfBrother
8 Replies

9. Shell Programming and Scripting

Resolving the environment variable from a file

Hi, I an having some environment variables exported and the variable name is present in the file. But its not resolving with following commands. Can someone throw some light. db $ grep -v "^#" TD_FWK_NUCLEUS.dbc | grep -v "^$" | xargs -i echo {} wb_bin: ${TD_FWK_NUCLEUS_DBC_WB_BIN_TAG} I... (3 Replies)
Discussion started by: Mohammed Rafi
3 Replies

10. Solaris

How to search for the sessions that have a certain environment variable set?

Hi all, In Solaris 10, is there a way to search for the sessions that have a certain environment variable set? (8 Replies)
Discussion started by: ejianu
8 Replies
CGI::Application::Plugin::Config::Simple(3pm)		User Contributed Perl Documentation	     CGI::Application::Plugin::Config::Simple(3pm)

NAME
CGI::Application::Plugin::Config::Simple - Add Config::Simple support to CGI::Application SYNOPSIS
in your CGI::Application based module use CGI::Application::Plugin::Config::Simple; sub cgiapp_init { my $self = shift; #set my config file $self->config_file('myapp.conf'); # #do other stuff # } #later on in a run mode sub run_mode1 { my $self = shift; #just get a single parameter from my config file my $value = $self->config_param('my_param'); #get a parameter in a block (if using ini style files) $value = $self->config_param('my_block.my_param'); #the entire config hash reference my $config_vars = $self->config_param(); #get my Config::Simple object for direct access my $config = $self->config; } DESCRIPTION
This module acts as a plugin for Config::Simple to be easily used inside of a CGI::Application module. It does not provide every method available from Config::Simple but rather easy access to your configuration variables. It does however provide direct access to the underlying Config::General object created if you want to use it's full power. The module tries to make the getting and setting of configuration variables as easy as possible. Only three methods are exported into your CGI::Application module and they are described below. Before I wrote this module sometimes I would put my code that read in the configuration file into the cgiapp_init() or cgiapp_prerun() methods but then if I had a run mode that didn't need those config variables it was run anyway. This module helps to solve this is. The Config::Simple object is not created (and the config file is not read and parsed) until after your first call to config() or config_param() to either retrieve/set values, or get the Config::Simple object. This lazy loading idea came from Cees Hek's CGI::Application::Plugin::Session module. METHODS
config_param() This method acts as an accessor/mutator for configuration variables coming from the configuration file. This method will behave in three different ways depending on how many parameters it is passed. If 0 parameters are passed then the entire config structure will be returned as a hash ref. If 1 parameters is passed then the value of that parameter in the config file will be returned. If more than 1 parameter is passed then it will treat them as name value pairs and will set the parameters in the config file accordingly. In this case, if we successfully set the parameters then a true value will be returned. #get the complete config hash my $config_hash = $self->config_param(); #just get one config value my $value = $self->config_param($parameter); #set multiple config values my $success = $self->config_param(param1 => $value1, param2 => $value2); This method uses Config::Simple so if you are using ini-files then you can set the values of variables inside blocks as well using the '.' notation. See Config::Simple; You must set the name of the configuration file either using the config_file() method or the CGIAPP_CONFIG_FILE environment variable before calling this method or it will 'die'. config() This method will return the underlying Config::Simple object for more direct use by your application. You must set the name of the configuration file either using the config_file() method or the CGIAPP_CONFIG_FILE environment variable before calling this method or it will 'die'. my $conf = $self->config(); config_file([$file_name]) This method acts as an accessor/mutator to either get the name of the current config file or to change/initialize it. This method must be called to initialize the name of the config file before any call can be made to either config() or config_param() unless the 'CGIAPP_CONFIG_FILE' environment variable has been set. If this environment variable is set it will be used as the initial value of the config file. This is useful if we are running in a mod_perl environment when can use a statement like this in your httpd.conf file: PerlSetEnv CGIAPP_CONFIG_FILE /path/to/my/conf It is typical to set the name of the config file in the cgiapp_init() phase of your application. If a value is passed as a parameter then the config file with that name is used. It will always return the name of the current config file. #get the value of the CGIAPP_CONFIG_FILE environment variable (if there is one) #since we haven't set the config file's name with config_file() yet. my $file_name = $self->config_file(); #set the config file's name $self->config_file('myapp.conf'); #get the name of the config file $file_name = $self->config_file(); CAVEATS
The CGI::Application object is implemented as a hash and we store the variables used by this module's methods inside of it as a hash named __CONFIG_SIMPLE. If you use any other CGI::Application plugins there would be problems if they also used $self->{__CONFIG_SIMPLE} but in practice this should never actually happen. AUTHOR
Michael Peters <mpeters@plusthree.com> Thanks to Plus Three, LP (http://www.plusthree.com) for sponsoring my work on this module SEE ALSO
o CGI::Application o Config::Simple LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.4 2011-11-10 CGI::Application::Plugin::Config::Simple(3pm)
All times are GMT -4. The time now is 11:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy