LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-16-2012, 06:06 AM   #1
jfjh201
LQ Newbie
 
Registered: Jun 2012
Posts: 2

Rep: Reputation: Disabled
bash - script not see environment variable running under sudo


my script contains string

Code:
echo $myvar
here's what i do in terminal

Code:
$ export myvar=1
$ ./myscript.sh
1
$ sudo ./myscript.sh

$
under sudo script does not see variable. how do i fix it?
 
Old 06-16-2012, 06:34 AM   #2
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
if you have "sudo" calling the script, but you define the VAR not in sudo environment then it can't follow it.
You will need some sudo configuration

good luck
 
  


Reply



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
[SOLVED] bash - script not see environment variable running under sudo jfjh201 Linux - Newbie 1 06-16-2012 07:23 PM
[SOLVED] sudo in bash script grep environment geep1980 Programming 15 11-28-2011 05:09 AM
How to export environment variable from a bash script dimaash Linux - Newbie 20 08-09-2011 07:12 AM
How to get environment variable from other user in bash script? Moonman Linux - General 5 01-13-2009 11:22 PM
Bash Script: Problem running variable command containing "" Paasan Programming 2 01-21-2004 01:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:14 AM.

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