Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-22-2009, 11:14 AM   #1
Registered: Mar 2005
Distribution: FC, Gentoo
Posts: 276

Rep: Reputation: 30
sudo perl script with environment variables

How to use sudo to run a perl script with the environment variable JAVA_HOME on linux?
Running as sudo do not pickup the environment variable JAVA_HOME

$ echo $JAVA_HOME
/home/powah/jdk1.6.0_13 is:
print "begin JAVA_HOME = $JAVA_HOME\n";
print "$ENV{'JAVA_HOME'} JAVA_HOME = $J_HOME\n";

$ perl
begin JAVA_HOME =
/home/powah/jdk1.6.0_13 JAVA_HOME = /home/powah/jdk1.6.0_13

$ sudo perl
begin JAVA_HOME =

Last edited by powah; 04-22-2009 at 11:18 AM.
Old 04-22-2009, 11:22 AM   #2
Registered: Feb 2009
Posts: 63

Rep: Reputation: 16
By default Sudo scrubs environment variables. The /etc/sudoers contains examples which ones it keeps by default, which ones you can keep and how to accomplish that.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
creating environment variables in perl iceman_san Linux - Newbie 7 08-11-2007 08:56 PM
Perl: Source shell script to for environment variables? stefanlasiewski Programming 3 02-07-2006 06:27 PM
Bash script environment variables mbjunior99 SUSE / openSUSE 4 12-28-2005 12:40 AM
Environment variables and perl jrbiochem Linux - General 0 05-06-2004 09:40 AM
Environment variables Perl nbp Programming 1 10-28-2003 08:49 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:15 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration