Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 73

Maybe you could just try

in your script

export LFS
1 members found this post helpful.
Old 08-25-2010, 07:36 AM   #17
LQ Newbie
Registered: Jul 2010
Posts: 2

Rep: Reputation: 0

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, 02:19 AM   #18
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`

Old 12-03-2010, 12:24 AM   #19
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 12:24 AM. Reason: bad writing
1 members found this post helpful.
Old 08-08-2011, 08:42 AM   #20
LQ Newbie
Registered: Mar 2005
Posts: 5

Rep: Reputation: 1
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.

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, 07:12 AM   #21
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?


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

All times are GMT -5. The time now is 07:35 PM.

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