7 ms·
If the shells script takes input parameters can we pass that and eventually turn it into some kind of web service ?
by eddywebs 13y ago
If the shells script takes input parameters can we pass that and eventually turn it into some kind of web service ?
- nitrogen 13y agoBy integrating anything shell-based with anything web-based you encounter a plethora of potential exploits and security holes. That said, if you need to run a script that requires command line parameters, and all you have is standard in, then write a wrapper script that reads N lines of text from stdin first, then parses those lines into the parameters you require. You have to be very conscious of input escaping and validation, though; otherwise your box will be owned in no time.
- joewalnes 13y agoI don't recommend any kind of input parsing in a shell script. You're better of having websocketd fork something like Python, Ruby, Perl, PHP, etc. Like CGI, websocketd will pass additional URL path and query parameters as environment variables. So you could access something like ws://somehost/?a=b and you'd access the QUERY_STRING environment variable in your script (which contains "a=b"). Virtually every scripting language already has a library for parsing CGI environment variables so you can do that. Basically, websocketd tries to emulate CGI as much as possible, but provide WebSocket streams instead of HTTP responses.