LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices

Reply
 
Search this Thread
Old 04-19-2004, 03:21 PM   #1
sylvain_gnu
Member
 
Registered: Mar 2004
Posts: 91

Rep: Reputation: Disabled
Lightbulb 'export' from a script doesn't work, why?


Hello,

I wish to use a script from time to time to set and export some variables, but I don't understand, it doesn't work! I probably have missed something basic, but I really don't get it...

Example:

script '/usr/bin/japanese_env', containing the following:
LANG=ja_JP.eucJP
LC_MESSAGES=ja_JP.eucJP
LC_CTYPE=ja_JP.eucJP
XMODIFIERS=@im=kinput2
#
export LANG
export LC_MESSAGES
export LC_CTYPE
export XMODIFIERS

In a terminal (xterm for instance), I wish that when I launch 'japanese_env',
the script exports the 4 variables LANG, LC_MESSAGES, LC_CTYPE, XMODIFIERS...
Which seems logical to me, but it doesn't work...
%japanese_env
%echo $LC_MESSAGES
fr_FR
instead of 'ja_JP.eucJP' as I expected.

I don't understand why, and I cannot find the answer in shell manuals.

Can you help?

Cheers,
Sylvain.

// Solution further below.

Last edited by sylvain_gnu; 04-20-2004 at 12:43 PM.
 
Old 04-19-2004, 05:54 PM   #2
souljah
Member
 
Registered: Feb 2004
Location: New York City
Distribution: Debian
Posts: 97

Rep: Reputation: 15
#!/bin/sh

export LANG=ja_JP.eucJP
export LC_MESSAGES=ja_JP.eucJP
export LC_CTYPE=ja_JP.eucJP
export XMODIFIERS=@im=kinput2

#EOF

why have two steps, when you can have one?
 
Old 04-19-2004, 06:07 PM   #3
sylvain_gnu
Member
 
Registered: Mar 2004
Posts: 91

Original Poster
Rep: Reputation: Disabled
Hello souljah,

I agree with that in this context "
why have two steps, when you can have one?
"

In fact at first I tried just as you wrote:

#!/bin/sh
export LANG=ja_JP.eucJP
export LC_MESSAGES=ja_JP.eucJP
export LC_CTYPE=ja_JP.eucJP
export XMODIFIERS=@im=kinput2

But it doesn't work either.


N.B: In a command line, it works, but I would rather use a script!
(don't want to type the 4 lines each time).
Sylvain.
 
Old 04-20-2004, 12:42 PM   #4
sylvain_gnu
Member
 
Registered: Mar 2004
Posts: 91

Original Poster
Rep: Reputation: Disabled
Lightbulb Solution

Someone gave me the solution I was looking for.

% . ./script
and the variables exported by 'script' will be available in the current shell.
% source ./script
has the same effect.

Cheers,
Sylvain.
 
  


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 export environment variable from a bash script dimaash Linux - Newbie 20 08-09-2011 07:12 AM
export call in bash script Donald1000 Linux - Software 10 03-12-2009 08:03 PM
export $PATH inside script gmitra Programming 3 02-01-2005 08:34 AM
set and export using bash script acummings Linux - General 10 01-03-2005 02:22 PM
export in a script movitto Linux - Software 3 08-27-2004 12:37 AM


All times are GMT -5. The time now is 01:13 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration