Environment file in Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Environment file in Perl
# 1  
Old 05-02-2013
Environment file in Perl

hi all,

i am new to perl scripting environment. i want to view the .env file. where'z the location of .env/.profile file in perl env.

Please suggest..

---------- Post updated at 10:53 AM ---------- Previous update was at 10:51 AM ----------

here is the path variable value:

bash-2.05$ echo $PATH
/home/dwhfeed:/usr/local/ActivePerl/bin:/opt/SUNWspro/bin:/apps/oracle/product/10.2.0.4.2012Q1/bin:/apps/oracle/product/10.2.0.4.2012Q1/ctx/bin:/bin:/opt/bin:/usr/ccs/bin:/usr/ucb:/usr/local/bin:.
# 2  
Old 05-02-2013
In perl, there's a special hash variable %ENV that has all the environment information in it.
For e.g., to know what's in the PATH, do this in perl:
Code:
print "$ENV{PATH}";

To know what more information is present in %ENV variable, try this on your command line:
Code:
perl -le 'for(keys %ENV) { print "$_ : $ENV{$_}" }'

# 3  
Old 05-02-2013
i had already tried this:
Code:
bash-2.05$ print "$ENV{PATH}"
bash: print: command not found

please suggest

Last edited by Franklin52; 05-02-2013 at 03:18 AM.. Reason: Please use code tags
# 4  
Old 05-02-2013
Quote:
Originally Posted by lovelysethii
i had already tried this:
Code:
bash-2.05$ print "$ENV{PATH}"
bash: print: command not found

please suggest
Try that in your perl script:
Code:
#! /usr/bin/perl
print "$ENV{PATH}";

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to change Linux Terminal environment variable in a perl or bash script?

Hi, I meet an problem that it cannot change Terminal environment variable in a perl or bash script. This change can only exist and become effective in script lifetime. But I want to make this change take effect in current opened Terminal. In our view, the thought seems to be impossible, As... (9 Replies)
Discussion started by: weichanghe2000
9 Replies

2. UNIX for Advanced & Expert Users

Issue Regarding environment/.profile file

Hi All, I have my own .profile file and environment file. To execute some commands I always need to load some module using module command and change my environment files to project environment file (. /some/project/some/path/init.environ).Without changing my environment file to project file,... (2 Replies)
Discussion started by: saps19
2 Replies

3. 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

4. Shell Programming and Scripting

Setting environment variables from a file :

Hi, I have around 10 environment variables in my shell script. i want to set this all in a file and just call that file in my shell script. How can i do that ? Please help. TIA! (6 Replies)
Discussion started by: qwertyu
6 Replies

5. Shell Programming and Scripting

Perl Csh - setenv ENV change environment variable

I have 3 programs, 1 in perl, 2 in csh: call them perl1, csh1 and run.ol I need perl1 to set csh1 variable NOLOG_qsub = "" I need perl1 to run, run.ol run.ol takes the executable and input and outputs to output run.ol#!/bin/csh -f # run.ol executable input output perl1 should... (1 Reply)
Discussion started by: austinj
1 Replies

6. Shell Programming and Scripting

run the file based on environment

Hi, I needed to run a script based on the environment..I'm just having some issue with the script..can someone help me ? #!/bin/ksh pat01=`uname -a | awk '{printf "%s", $2}'` #if it is server 1 run this file if ; then echo "run this file" #if it is server 2 run this file... (5 Replies)
Discussion started by: moe458
5 Replies

7. Shell Programming and Scripting

Set Environment variable from another file

Hi, i have the following env variable. currently i am exporting variable in the same script file. but i need this is in a text file and the scripts need to export this variable from the text file. can you please suggest me. is it possible. export... (6 Replies)
Discussion started by: rsivasan
6 Replies

8. Shell Programming and Scripting

perl. How to set persistent environment variables

I have test.pl scrit with these few lines. #!/usr/bin/perl $ENV{'ORACLE_SID'} = "D3771"; $ENV{'ORACLE_HOME'} = "/oracle/product/10.2.0/db_1"; When I try . test.pl it throws an error. When I try test.pl, it doesn't reaing the variables I set in the script. -> . test.pl ksh:... (10 Replies)
Discussion started by: MKNENI
10 Replies

9. Shell Programming and Scripting

Help: how to convert perl script to awk in windows2003 server environment

For the following perl script, can anyone help to convert it to awk statement in windows2003 server environment ? Code: foreach $k (sort {$a <=> $b} keys %psnum) (1 Reply)
Discussion started by: tojzz
1 Replies

10. Shell Programming and Scripting

Environment variables in Perl

I don't use perl very often, and am stuck on how to create a perl variable from a literal and an environment variable; eg $FILE='/u/output'+env($UNIQUE_ID); Also how does the Apache web server create the UNIQUE_ID environment variable, and will an 8 character substring from 3 to 10 incl, in... (2 Replies)
Discussion started by: jgt
2 Replies
Login or Register to Ask a Question