我从文件运行一个命令时遇到问题。
当我直接在终端中执行命令时,一切正常,软件运行良好。如果我尝试从文件运行它,则始终存在一个文件错误。
如果我使用此命令和完整路径直接在终端中运行它,则它可以正常工作:
/home/lukas/snap/bin/gpt /home/lukas/Desktop/automatic/test/resample_s2.xml -e -p /home/lukas/Desktop/automatic/test/resample_20m.properties -t "/home/lukas/Desktop/automatic/outputs/processed.dim" /home/lukas/Desktop/automatic/inputs/S2A_MSIL2A_20170717T095031_N0205_R079_T34UCV_20170717T095631.SAFE/MTD_MSIL2A.xml
当我从脚本运行此命令时,它将对xml
文件引发错误。
#!/bin/bash
gpt=/home/lukas/snap/bin/gpt
xml= /home/lukas/Desktop/automatic/test/resample_s2.xml
properties=/home/lukas/Desktop/automatic/test/resample_20m.properties
output=/home/lukas/Desktop/automatic/outputs/processed.dim
input=/home/lukas/Desktop/automatic/inputs/S2A_MSIL2A_20170717T095031_N0205_R079_T34UCV_20170717T095631.SAFE/MTD_MSIL2A.xml
$gpt $xml -e -p $properties -t $output $input
错误是:
/home/lukas/Desktop/automatic/test/resample_s2.xml: line 1: syntax error near unexpected token `newline'
/home/lukas/Desktop/automatic/test/resample_s2.xml: line 1: `<graph id="Resample_Sentinel-2">'
我执行的是:
bash gpt_test.sh
但是xml
两种情况下文件都是相同的。它在终端中正常处理,但是尝试从脚本运行它时出现错误。
这是罪魁祸首:
xml= /home/lukas/Desktop/automatic/test/resample_s2.xml
您必须在之后删除空格=
。使用空格,它尝试作为单独的命令执行分配的正确部分,这解释了为什么它在XML文件中显示有关“意外令牌”的错误。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句