請問shell script中export環境變數的問題 - Linux

By Adele
at 2008-09-16T14:07
at 2008-09-16T14:07
Table of Contents
要有 父子行程 的觀念,子行程可以繼承父行程的環境變數,
反之則否。
所以,你的例子是錯誤的,你可以改成。
#script2
export PORT=Linux
echo $PORT
#end of file
==================
#script1
PORT=`./script2`
echo $PORT
#end of file
或者,把 export 宣告放在 script1 (父行程),
script2 (子行程) 再去使用就可以了。
※ 引述《wahoho (..)》之銘言:
: 如果現在有兩個script
: script1和script2
: 內容分別是
: #script2
: export PORT=Linux
: #end of file
: =============
: #script1
: ./script2
: echo $PORT
: #end of file
: 請問有辦法讓script2中export的變數繼續存在script1裡面嗎?
--
I'm root.
--
Tags:
Linux
All Comments
Related Posts
請問Linux下測試記憶體的程式?

By Ursula
at 2008-09-16T14:00
at 2008-09-16T14:00
請問Linux下測試記憶體的程式?

By David
at 2008-09-16T10:25
at 2008-09-16T10:25
postfix搭配MUA該架設什麼服務?

By Isla
at 2008-09-16T09:52
at 2008-09-16T09:52
mysql資料庫匯出

By Joe
at 2008-09-16T00:42
at 2008-09-16T00:42
請問shell script中export環境變數的問題

By Frederica
at 2008-09-15T22:54
at 2008-09-15T22:54