msoap / shell2http

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

exec error: exit status 1 #56

Closed selvakumar7991 closed 4 years ago

selvakumar7991 commented 4 years ago

C:\Selva\software\shell2http>shell2http -form /starttest "C:\Selva\software\shell2http\script.bat" 2020/03/02 14:17:56 register: /starttest (C:\Selva\software\shell2http\script.bat) 2020/03/02 14:17:56 register: / (index page) 2020/03/02 14:17:56 listen http://:8080/ 2020/03/02 14:18:05 localhost:8080 [::1]:55677 GET /starttest "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36" 2020/03/02 14:18:05 exec error: exit status 1

Getting above error when we tired an api for executing a bat file http://localhost:8080/starttest

msoap commented 4 years ago

The reason is that the script (script.bat) exits with code 1. You can try use -show-errors option for show this error in browser.

selvakumar7991 commented 4 years ago

image My browser showing empty response after adding -show-errors option for show this error in browser like below

shell2http -form -show-errors /starttest "C:\Selva\software\shell2http\script.bat" 2020/03/02 15:32:07 register: /starttest (C:\Selva\software\shell2http\script.bat) 2020/03/02 15:32:07 register: / (index page) 2020/03/02 15:32:07 listen http://:8080/ 2020/03/02 15:32:09 localhost:8080 [::1]:57083 GET /starttest "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36" 2020/03/02 15:32:09 exec error: exit status 1

msoap commented 4 years ago

sorry, it turned out that this option is about another. Anyway, you should investigate your script, why it exits with code 1

selvakumar7991 commented 4 years ago

okay thanks man

selvakumar7991 commented 4 years ago

image

I tired with basic command in the bat file, Still getting above error only, Do you any idea about this

selvakumar7991 commented 4 years ago

shell2http -form /starttest "C:\Selva\software\shell2http\sam.bat" 2020/03/02 15:56:06 register: /starttest (C:\Selva\software\shell2http\sam.bat) 2020/03/02 15:56:06 register: / (index page) 2020/03/02 15:56:06 listen http://:8080/ 2020/03/02 15:56:09 localhost:8080 [::1]:58464 GET /starttest "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" 2020/03/02 15:56:09 exec error: exit status 1 2020/03/02 15:56:11 localhost:8080 [::1]:58464 GET /starttest "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" 2020/03/02 15:56:11 exec error: exit status 1

msoap commented 4 years ago

I don’t have Windows right now, but please try that script:

ipconfig

if errorlevel 1 (
   echo Failure reason given is %errorlevel%
   exit /b 0
)

and run command like this:

shell2http -include-stderr /starttest "c:\path\to\script\sam.bat"
selvakumar7991 commented 4 years ago

image

still getting same issue. let me try this same in linux machine

selvakumar7991 commented 4 years ago

image

msoap commented 4 years ago

You should use real path to script, not "c:\path\to\script\sam.bat" (this is example)

msoap commented 4 years ago

And please just run this script from terminal, is it running normally?

selvakumar7991 commented 4 years ago

image ran this script from terminal, it is running fine

selvakumar7991 commented 4 years ago

image folder structure for your reference

msoap commented 4 years ago

i see - test.bat is nothing output

msoap commented 4 years ago

you can use ipconfig directly:

shell2http -include-stderr /starttest ipconfig
selvakumar7991 commented 4 years ago

tired to use directly, but getting different error

shell2http.exe -include-stderr -port=8010 /test "C:\Selva\NeoLoad 7.2\bin\NeoLoadCmd.exe" 2020/03/03 12:27:41 register: /test (C:\Selva\NeoLoad 7.2\bin\NeoLoadCmd.exe) 2020/03/03 12:27:41 register: / (index page) 2020/03/03 12:27:41 listen http://:8010/ 2020/03/03 12:27:49 localhost:8010 [::1]:58124 GET /test "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36" 2020/03/03 12:27:59 exec error: exit status 3221226505

msoap commented 4 years ago

script (or any program) must be return 0 exit code, in any other case there will be such an error

selvakumar7991 commented 4 years ago

Planning to build an own API according to my recruitment, Anyway, Thanks for your help