简体   繁体   中英

How to Run Shell Scripts on server using Browser

I am having shell script whose output is output.zip.

i want to Run Shell script on server using browser and download output.zip.

Please suggest me how i can do this, which technology i should use.

Not sure about your server platform but I assume you have JAVA there and you can handle http request.

Create output file with this command:

Runtime.getRuntime().exec("sh test.sh");

The second part is to stream content of your file as response. Just set response header to

Content-Description: File Transfer 
Content-type: application/octet-stream
Content-Disposition: attachment; filename="YourFilename.zip"
Content-Transfer-Encoding: binary
Content-Length: LengthOfYourFileInBytes

and you can send your file content as body of the response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM