日期:2014-05-16  浏览次数:20807 次

linux下把环境变量的设置export 放到shell 脚本中?
我想用脚本设置环境变量,想把export放到脚本里。这是我写的脚本:export.sh
#!/bin/sh
export $='/opt/Qtopia4.4.3/bin:/sbin:/usr/sbin:/bin:/usr/bin'
export QPEDIR='/opt/Qtopia4.4.3'
export QTDIR='/opt/Qtopia4.4.3'
export QT_QWS_FONTDIR='/opt/Qtopia4.4.3/lib/fonts/'
export QT_PLUGIN_PATH='/opt/Qtopia4.4.3/plugins:/opt/Qtopia4.4.3/qt_plugins/'
export LD_LIBRARY_PATH='/opt/Qtopia4.4.3/lib'
echo "IT IS OK"

用sh 执行是没有效果的,但用source 确被告知-/bin/sh: source: export.sh: not found  

大家看看,我该怎么做呢??谢谢大家


------解决方案--------------------
source export.sh 不行吗
------解决方案--------------------
去掉#!/bin/sh

------解决方案--------------------
C/C++ code

#!/bin/bash
export $='/opt/Qtopia4.4.3/bin:/sbin:/usr/sbin:/bin:/usr/bin'
export QPEDIR='/opt/Qtopia4.4.3'
export QTDIR='/opt/Qtopia4.4.3'
export QT_QWS_FONTDIR='/opt/Qtopia4.4.3/lib/fonts/'
export QT_PLUGIN_PATH='/opt/Qtopia4.4.3/plugins:/opt/Qtopia4.4.3/qt_plugins/'
export LD_LIBRARY_PATH='/opt/Qtopia4.4.3/lib'
echo "IT IS OK"

#chmod 755 export.sh
#source export.sh

------解决方案--------------------
. ./export.sh
------解决方案--------------------
第一行改成#!/bin/bash