1

Execute bash script with params from Javascript

view story
linux-howto

http://stackoverflow.com – I have some Javascript code that is used to determine a param that has to be then forwarded to a bash script on the target device. The bash script then copies a new file across and does a reboot of the system. I am using AJAX to do the call to the bash script and the code is as follows: var config = get_config(); // Simply returns an integer var xml_http = get_xml_http_object(); xml_http.open("GET", bash_script_id + "?" + config, false); xml_http.send(null); The bash script looks as follows #!/bin/sh CONFIG_NUMBER="$1" cp /config_file$CONFIG_NUMBER /file_to_use reboot The script is (HowTos)