Как получить доступ к значениям, отправленным с помощью xmlHttpReq.send
в bash?
В Perl я могу получить доступ к данным, отправленным из файла html / javascript, как:
#!/usr/bin/perl -w
use CGI;
$query = new CGI;
$secretword = $query->param('w');
print $query->header;
print "<p>The secret word is <b>$secretword</b></p>"
Я пытаюсь получить доступ к 'w' в скрипте sh, но чтение из / dev / stdin не работает. В браузере ничего не отображается.
#!/bin/sh
echo "Content-type: text/html"
echo ""
echo $(</dev/stdin)
Как я могу получить доступ к данным, отправленным через POST в sh? * * 1010
Вот используемый файл html / javascript:
<html>
<head>
<title>Ajax Example</title>
<script language="Javascript">
function xmlhttpPost(strURL) {
var xmlHttpReq = false;
var self = this;
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring());
}
function getquerystring() {
var form = document.forms['f1'];
var word = form.word.value;
qstr = 'w=' + escape(word);
return qstr;
}
function updatepage(str){
document.getElementById("result").innerHTML = str;
}
</script>
</head>
<body>
<form name="f1">
<p>word: <input name="word" type="text">
<input value="Go" type="button" onclick='JavaScript:xmlhttpPost("./cgi-bin/test_ajax_bash.sh")'></p>
<div id="result"></div>
</form>
</body>
</html>