我有一個奇怪的問題。當我直接從命令行運行腳本時,它工作正常。但是當我從Java Script執行它時,remoteCall函數未被執行。任何幫助表示讚賞。無法在cgi-BashScript中調用函數
#!/bin/bash
echo "Content-type: text/html"
echo ""
SERVER="SERVER";
USERNAME="username";
THRESHOLD="70"; # % Space occupied on disk.
DF_COMMAND="df -Pkh";
function remoteCall() {
echo "remote call "
local RESULT;
RESULT=$(ssh [email protected]$SERVER $1);
echo "$RESULT";
}
# Starting point for the script
function main() {
echo "main function"
local DF_Result=$(remoteCall "$DF_COMMAND"); # This function doesn't get called.
echo "$DF_Result"
}
main
Java腳本代碼中調用的腳本是:
cgiUrl="cgi-bin/scanner.cgi";
function diskCheckingScript() {
$.post(cgiUrl, function(result) {
console.log("Result is",result);
});
}
並調用它的JavaScript代碼? – konsolebox
在代碼中添加JavaScript代碼。 – Amber
'$ DF_COMMAND','$ USERNAME'和'$ SERVER'從何處獲取它們的值? –