msoap / shell2http

Executing shell commands via HTTP server
MIT License
1.34k stars 132 forks source link

Parsing of ASCII encoding not working for all characters #81

Closed MNM-TB closed 2 years ago

MNM-TB commented 2 years ago

Hi,

Thank you for a fantastic tool! It is a godsend when working with docker-compose. I have however run into a very strange issue. I'm trying to get ImageJ/Fiji up and running in a container receiving commands via shell2http.

The command I'm trying to execute is:

ImageJ-linux64 --ij2 --headless --run /tmp/outdata/demo.py 'name="Tomas"'

where the name=Tomas is the variable I need to send into the script demo.py . If I enter the running docker container this command executes successfully. However, when I send it through shell2http it spits out an error on the quoted variable. The error is "Ignoring extraneous argument" but that is probably ImageJ specific.

First I thought that the error had to do with my encoding of the multiple quotes. I have used this table for the translation: https://www.w3schools.com/tags/ref_urlencode.asp

and the URL I send is:

curl 'http://fiji:8083/data?args=--ij2%20--headless%20--run%20/tmp/outdata/demo.py%20%27name%3D%22Tomas%22%27'

To trouble shoot it I have inserted an echo statement In the Dockerfile i.e.,

ENTRYPOINT /app/shell2http -port 8083 -form /data 'echo $v_args && /opt/fiji/Fiji.app/ImageJ-linux64 $v_args'

And the echo statement displays the arguments correctly i.e.,

--ij2 --headless --run /tmp/outdata/demo.py 'name="Tomas"'

Any help is highly appreciated!

msoap commented 2 years ago

Hi, if i understand correctly, ImageJ-linux64 treats the passed argument as one. Please try to pass each argument in separated variable, e.g.:

ENTRYPOINT /app/shell2http -port 8083 -form /data '/opt/fiji/Fiji.app/ImageJ-linux64 $v_arg1 $v_arg2 $v_arg3 $v_arg4'

and call:

curl 'http://fiji:8083/data?arg1=--ij2%20&arg2=--headless&arg3=--run&arg3=/tmp/outdata/demo.py&arg4=name%3D%22Tomas%22'