I have a problem running one command from a file.
When I execute command directly in terminal everything is working and software do it well. If I try to run it from the file, there is error with one file all the time.
If I run it directly in terminal with this command and full paths it is working:
/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
Run Code Online (Sandbox Code Playgroud)
When I run this command from a script, it throws an error with an xml file.
#!/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
Run Code Online (Sandbox Code Playgroud)
The error is:
/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">'
Run Code Online (Sandbox Code Playgroud)
I execute is as:
bash gpt_test.sh
Run Code Online (Sandbox Code Playgroud)
But the xml file is the same in both cases; it is working properly processed in terminal, but there is an error when I try to run it from a script.
Byt*_*der 10
This line is the culprit:
xml= /home/lukas/Desktop/automatic/test/resample_s2.xml
Run Code Online (Sandbox Code Playgroud)
You must remove the space after =. With the space, it tries to execute the right part of the assignment as separate command, which explains why it shows errors about "unexpected tokens" in the XML file.