LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-24-2010, 02:27 PM   #16
gdejonge
Member
 
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317

Rep: Reputation: 73

Maybe you could just try

Code:
export VARIABLE
in your script

Code:
LFS=/mnt/lfs
export LFS
 
1 members found this post helpful.
Old 08-25-2010, 08:36 AM   #17
DElimitER
LQ Newbie
 
Registered: Jul 2010
Posts: 2

Rep: Reputation: 0
Example...

function foo()
{
export VARIABLE="Something"
}

Functions are executing in current environment so creating and exporting VARIABLE is the same as if you had typed it in the shell directly, or in the script and run it with source or . (dot) built-in. You can make function by writing it in the shell directly or write it in the script and run script with 'source ./script... =)
 
Old 11-25-2010, 03:19 AM   #18
cosminadrianpopescu
LQ Newbie
 
Registered: Sep 2010
Posts: 8

Rep: Reputation: 0
It's not a solution, but at least this is an workaround:

In your script do something like:

echo MY_VAR >/tmp/my_var.value

In the script in which you want to use the variable value, do something like this, for example:

gcc my_script.cpp -I`cat /tmp/my_var.value`

Cosmin.
 
Old 12-03-2010, 01:24 AM   #19
mangueJOE
Member
 
Registered: Nov 2001
Location: Brazil
Distribution: Ubuntu, Debian
Posts: 66

Rep: Reputation: 16
This highlander thread was usefull to me as well. Cheers!

Last edited by mangueJOE; 12-03-2010 at 01:24 AM. Reason: bad writing
 
1 members found this post helpful.
Old 08-08-2011, 09:42 AM   #20
domino1241
LQ Newbie
 
Registered: Mar 2005
Posts: 5

Rep: Reputation: 1
Quote:
Originally Posted by Tinkster View Post
Not sure what that was a reference to ... I'm referring
to the fact that this thread is from 2005; it died, got
re-animated in August 2009, died, and got dug up again in
August this year.



Cheers,
Tink
I don't understand what the moderators have against people bringing up old threads. If Google returns this forum thread for a query for a common problem, it shouldn't matter how old the last post was, as long as it is still relevant.

On topic: I was having the same problem using source and export in a bash file, and the leading dot makes it so I the environmental variables appear in the command line after the script finishes. I would like to see someone demonstrate the use of functions though, so I have a second way of fixing the problem should it arise again. If anyone is inclined to include such a demo, I (and all the others who come upon this thread after me) would be very grateful.
 
1 members found this post helpful.
Old 08-09-2011, 08:12 AM   #21
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
@domino1241: What do you mean by a demonstration with the use of functions.. What problem needs to be fixed?
 
  


Reply


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
how to unset environment variable in bash suneel Linux - Newbie 7 09-14-2009 11:17 AM
export call in bash script Donald1000 Linux - Software 10 03-12-2009 09:03 PM
cannot export result from awk into a variable in a bash script Emmanuel_uk Linux - Newbie 4 03-07-2005 02:54 AM
set and export using bash script acummings Linux - General 10 01-03-2005 03:22 PM
BASH variable export Barbarian Programming 2 11-27-2001 09:37 PM


All times are GMT -5. The time now is 06:36 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration