当前位置: 技术问答>linux和unix
linux下把环境变量的设置export 放到shell 脚本中?
来源: 互联网 发布时间:2017-02-22
本文导语: 我想用脚本设置环境变量,想把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/...
我想用脚本设置环境变量,想把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
大家看看,我该怎么做呢??谢谢大家
#!/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
大家看看,我该怎么做呢??谢谢大家
|
去掉#!/bin/sh
|
#!/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
|
source export.sh 不行吗
|
第一行改成#!/bin/bash