
我跟著這個教學為所有使用者新增 JAVA 變數。然後,我打開託管服務提供的編輯器並添加最後兩行。森托斯 5.9伺服器.
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
# ksh workaround
if [ -z "$EUID" -a -x /usr/bin/id ]; then
EUID=`id -u`
UID=`id -ru`
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1
if [ -x /usr/bin/id ]; then
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. $i
else
. $i >/dev/null 2>&1
fi
fi
done
unset i
unset pathmunge
#cPanel Added local::lib -- BEGIN
LOCALLIBUSER=$USER
if [ -e "/usr/bin/whoami" ]; then
LOCALLIBUSER=`/usr/bin/whoami`
fi
if [ "$LOCALLIBUSER" != "root" ]; then
eval $(perl -Mlocal::lib)
fi
#cPanel Added local::lib -- END
export PATH=$PATH:/opt/java/jdk1.6.0_41/bin
export PATH=$PATH:/opt/java/jdk1.6.0_41/bin
重新登入後我得到:
問題是我需要配置 Java home 變數。即使我刪除了最後兩行添加的內容,我仍然收到該錯誤。謝謝。
答案1
它看起來非常像您使用的編輯器將換行符('\n')字元(在數字上等於換行(LF)字元)更改為 CR+LF 序列(CR = 回車符)。總的來說,您顯示的錯誤訊息沒有多大意義,但這部分讓我感到驚訝:
…bash: /etc/profile: line 6: syntax error near unexpected token `{
'
也就是說,「意外標記」後面跟著{
一個 CR。