Linux 导出不在shell中工作

Linux 导出不在shell中工作,linux,bash,shell,Linux,Bash,Shell,下面我粘贴了我的示例- #!/bin/sh #. /root/file.txt su - root -c "/bin/sh" << EOF if [[ -f /root/file.txt ]] ; then . /root/file.txt export X=$X:/nobin <-- not exporting correctly. Incase line no 2 is uncommented, it works. else echo "ERROR

下面我粘贴了我的示例-

#!/bin/sh
#. /root/file.txt 
su - root -c "/bin/sh" << EOF        
if [[ -f /root/file.txt ]] ; then

. /root/file.txt 
export X=$X:/nobin  <-- not exporting correctly. Incase line no 2 is uncommented, it works.
else

echo "ERROR: /root/path.txt file is missing"
     exit 1
fi

echo "myexecutable_binary 2>&1"   
EOF

echo $?

echo "here"
正如我在上面强调的,出口有一些问题。请帮我把这个修好


Linux-Linux 2.6.18-348.el5

当前shell正在插入您的here文档。我猜在运行这个程序的shell中没有定义变量
X
。我还推测,您实际上希望脚本不被插入。一个简单的修复方法是引用herdoc分隔符<代码>“导出有问题”什么问题?您如何确定导出不起作用?另外,从代码段中删除大量不相关的垃圾。您遇到了什么问题?行号注释为:-#./new.sh+/root/file.txt++X=/usr/usr1:/usr/usr2++export X++echo/usr/usr1:/usr/usr2/usr/usr1:/usr/usr2+export X=:/nobin+X=:/nobin+set+X binary 2>&10此处#vi new.sun-注释行第2:-#/new.sh/usr/usr1:/usr/usr2+/root/file.txt++X=/usr/usr1:/usr/usr2++export X++echo/usr/usr1:/usr/usr1:/usr/usr2+export X=/usr/usr1:/nobin+X=/usr/usr1:/usr/usr2:/nobin+set+X binary 2>&10这里的区别是->export X=/usr/usr:/usr/usr/usr2:/nobin,但我面临的问题是,在这一块中,那些不应该立即扩大的美元符号将被反斜杠。你的问题确实应该解释你的要求,包括那些仅仅暗示但没有得到适当解释的要求,以及那些在问题中甚至没有暗示的额外要求。
X="/usr/usr1:/usr/usr2"


export X

echo $X