msoap / shell2http

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

I receive the error "command not found", but actually exists #72

Closed felinto-dev closed 3 years ago

felinto-dev commented 3 years ago

When I run this command I get this error message:

shell2http -export-all-vars -shell="bash" -form /unblock-ip "csf -g $v_ip"
[root@acesso ~]# shell2http -export-all-vars -shell="bash" -form /unblock-ip "csf -g $v_ip"
2021/03/17 14:26:29 register: /unblock-ip (csf -g )
2021/03/17 14:26:29 register: / (index page)
2021/03/17 14:26:29 listen http://localhost:8080/
2021/03/17 14:26:31 /unblock-ip - 404
bash: csf: command not found

I can affirm that this command exists.

msoap commented 3 years ago

Hi, you can debug this shell issue by adding an additional route to print your PATH, like this

shell2http -export-all-vars -shell=bash -form /test 'echo $PATH'

and you can check if the directory with your utility is included in the PATH

Also using double quotes will not work when using variables ($v_ip) because your shell expands variable before run shell2http, you should use single quotes: /unblock-ip 'csf -g $v_ip'

felinto-dev commented 3 years ago

Thanks! I can see that the "csf" utility is in the PATH environment variable:

[root@acesso public_html]# echo $SHELL
/bin/bash
[root@acesso public_html]# which csf
/usr/sbin/csf
[root@acesso public_html]# shell2http -export-all-vars -shell=bash -form /test 'echo $PATH'
2021/03/17 17:17:50 register: /test (echo $PATH)
2021/03/17 17:17:50 register: / (index page)
2021/03/17 17:17:50 listen http://localhost:8080/

I receive the result in my browser: /snap/shell2http/120/usr/sbin:/snap/shell2http/120/usr/bin:/snap/shell2http/120/sbin:/snap/shell2http/120/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games "/usr/sbin" is in list.

[root@acesso public_html]# shell2http -export-all-vars -shell="bash" -form /unblock-ip 'csf -g $v_ip'
2021/03/17 17:19:40 register: /unblock-ip (csf -g $v_ip)
2021/03/17 17:19:40 register: / (index page)
2021/03/17 17:19:40 listen http://localhost:8080/

I still receive the same error using single quotes.

msoap commented 3 years ago

/snap/... do you use snap installation of shell2http?

The snap-package has its own sandbox with the /bin, /usr/bin directories which are not equal to system-wide PATH directories. Please use another type of installation, for example deb-package from release page.

felinto-dev commented 3 years ago

Thanks! I install the binary and now works!