Subversion Repositories php-qbpwcf

Rev

Blame | Last modification | View Log | RSS feed

<?php

#使用命名空間
namespace qbpwcf;

#匯入外部套件
include("../allInOne.php");

#提示目前執行的方法
echo "<hr>external::callShell - testCase 1<p>";

/*

#涵式說明:
#呼叫shell執行系統命令,並取得回傳的內容.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["cmd"],執行的指令內容.
#$result["output"],爲執行完二元碼後的輸出陣列.
#$result["outputFromFile"]["fileContent"],取得輸出的內容陣列.
#$result["outputFromFile"]["lineCount"],取得輸出內容總共的行數.
#$result["outputFromFile"]["fullContent"],取得輸出的內容陣列.
#必填的參數
#$conf["command"],字串.
$conf["command"]="uname -a";#要執行的指令與參數.
#可省略參數:
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
#$conf["enablePrintDescription"]="true";
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
#$conf["printDescription"]="";
#參考資料:
#exec=>http://php.net/manual/en/function.exec.php
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
var_dump(external::callShell($conf));
unset($conf);

*/

#提示目前執行的方法
echo "<hr>external::callShell - testCase 2<p>";

/*

#涵式說明:
#呼叫shell執行系統命令,並取得回傳的內容.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["cmd"],執行的指令內容.
#$result["output"],爲執行完二元碼後的輸出陣列.
#必填的參數
#$conf["command"],字串,要執行的指令與.
$conf["command"]="dnf check-update";
#可省略參數:
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
#$conf["argu"]=array("");
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
#$conf["enablePrintDescription"]="true";
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
#$conf["printDescription"]="";
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
#$conf["escapeshellarg"]="false";
#$conf["username"],字串,要用什麼使用者來執行,預設為執行apache的使用者.
$conf["username"]="root";
#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼.
$conf["password"]="superFedoraLinux";
#備註:
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.
#參考資料:
#exec=>http://php.net/manual/en/function.exec.php
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
var_dump(external::callShell($conf));
unset($conf);

*/

#提示目前執行的方法
echo "<hr>external::callShell - testCase 3<p>";

/* 因為apache無法執行java所以會失敗

#涵式說明:
#呼叫shell執行系統命令,並取得回傳的內容.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["cmd"],執行的指令內容.
#$result["output"],爲執行完二元碼後的輸出陣列.
#$result["outputFromFile"]["fileContent"],取得輸出的內容陣列.
#$result["outputFromFile"]["lineCount"],取得輸出內容總共的行數.
#$result["outputFromFile"]["fullContent"],取得輸出的內容陣列.
#必填的參數
#$conf["command"],字串.
$conf["command"]="java";#要執行的指令與參數.
#可省略參數:
#$conf["argu"],字串,指令搭配的參數,預設為"".
$conf["argu"][]="externel/webService";
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
#$conf["enablePrintDescription"]="true";
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
#$conf["printDescription"]="";
#參考資料:
#exec=>http://php.net/manual/en/function.exec.php
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
var_dump(external::callShell($conf));
unset($conf);

*/

#提示目前執行的方法
echo "<hr>external::callShell - testCase 4<p>";

/* 

#涵式說明:
#呼叫shell執行系統命令,並取得回傳的內容.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["cmd"],執行的指令內容.
#$result["output"],爲執行完二元碼後的輸出陣列.
#必填的參數
#$conf["command"],字串,要執行的指令與.
$conf["command"]="lshw";
#$conf["fileArgu"],字串,變數__FILE__的內容,預設為當前檔案的路徑與名稱.
$conf["fileArgu"]=__FILE__; 
#可省略參數:
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
#$conf["argu"]=array("");
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
#$conf["enablePrintDescription"]="true";
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
#$conf["printDescription"]="";
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
#$conf["escapeshellarg"]="false";
#$conf["username"],字串,要用什麼使用者來執行,預設為執行apache的使用者.
#$conf["username"]="root";
#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼.
#$conf["password"]="superFedoraLinux";
#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要;"false"代表不要,預設為"false".
#$conf["useScript"]="";
#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 ".qbpwcf_tmp/external/callShell/".
#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要.
$conf["inBackGround"]="true";
#備註:
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.使用root身份可能會被selinux阻擋.
#參考資料:
#exec=>http://php.net/manual/en/function.exec.php
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
var_dump(external::callShell($conf));
unset($conf);

*/

#提示目前執行的方法
echo "<hr>external::callShell - testCase 5<p>";

/*

#涵式說明:
#呼叫shell執行系統命令,並取得回傳的內容.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["cmd"],執行的指令內容.
#$result["output"],爲執行完二元碼後的輸出陣列.
#必填的參數
#$conf["command"],字串,要執行的指令與.
$conf["command"]="uname -a";
#$conf["fileArgu"],字串,變數__FILE__的內容.
$conf["fileArgu"]=__FILE__;             
#可省略參數:
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
#$conf["argu"]=array("");
#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
#$conf["arguIsAddr"]=array();
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
#$conf["enablePrintDescription"]="true";
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
#$conf["printDescription"]="";
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
#$conf["escapeshellarg"]="false";
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
#$conf["username"]="";
#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
#$conf["password"]="";
#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要;"false"代表不要,預設為"false".
$conf["useScript"]="true";
#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
#$conf["inBackGround"]="";
#備註:
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
#參考資料:
#exec=>http://php.net/manual/en/function.exec.php
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php                   
$callShell=external::callShell($conf);
unset($conf);
var_dump($callShell);

*/

#提示目前執行的方法
echo "<hr>external::callShell - testCase 6<p>";

/*

#涵式說明:
#呼叫shell執行系統命令,並取得回傳的內容.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["cmd"],執行的指令內容.
#$result["output"],爲執行完二元碼後的輸出陣列.
#必填的參數
#$conf["command"],字串,要執行的指令與.
$conf["command"]="ls";
#$conf["fileArgu"],字串,變數__FILE__的內容.
$conf["fileArgu"]=__FILE__;     
#可省略參數:
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
$conf["argu"]=array("-alh","/home/liveuser/Downloads");
#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
$conf["arguIsAddr"]=array("false","true");
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
#$conf["enablePrintDescription"]="true";
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
#$conf["printDescription"]="";
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
#$conf["escapeshellarg"]="false";
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
#$conf["username"]="";
#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
#$conf["password"]="";
#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要;"false"代表不要,預設為"false".
#$conf["useScript"]="true";
#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
#$conf["inBackGround"]="";
#備註:
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
#參考資料:
#exec=>http://php.net/manual/en/function.exec.php
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php                   
$callShell=external::callShell($conf);
unset($conf);
var_dump($callShell);

*/

#提示目前執行的方法
echo "<hr>external::callJava<p>";

/*

#編譯java檔
#涵式說明:
#呼叫shell執行系統命令,並取得回傳的內容.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列
#$result["output"],爲執行完二元碼後的輸出陣列
#$result["function"],當前執行的函數名稱
#必填的參數
#$conf["command"],字串.
$conf["command"]="javac";#要執行的指令與參數.
#可省略參數:
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
$conf["argu"]=array("externalT/webService.java");
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
#$conf["enablePrintDescription"]="true";
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
#$conf["printDescription"]="";
#參考資料:
#http://php.net/manual/en/function.exec.php
var_dump(external::callShell($conf));
unset($conf);

#涵式說明:
#測試php呼叫java後回傳的結果 
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列
#$result["output"],爲執行完二元碼後的輸出陣列
#必填的參數:
$conf["javaClassFileAddress"]="externalT/webService";#java class檔案的位置與名稱,附檔名(.class)不用附上。
#可省略的參數:
$conf["arguments"]="-t1";#要給java class檔案的參數
#參考資料:
#http://php.net/manual/en/function.exec.php
var_dump(external::callJava($conf));
unset($conf);

*/

#提示目前執行的方法
echo "<hr>external::execByteCode<p>";

/*

#涵式說明:
#測試php呼叫shell後回傳的結果
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列
#$result["output"],爲執行完二元碼後的輸出陣列
#必填的參數
$conf["exeFileAddress"]="externalT/cmd.bin";#可執行檔的位置與名稱
#可省略的參數:
$conf["arguments"]="ls -al";#要給執行檔的參數
#參考資料:
#http://php.net/manual/en/function.exec.php
var_dump(external::execByteCode($conf));
unset($conf);

*/

#提示目前執行的方法
echo "<hr>external::compileCppThenDownload<p>";

/*

#函式說明:
#編譯C++檔案,下載輸出的2元碼.
#回傳的結果:
#當 $conf["noDownload"] 設為 "true" 或執行出錯時 才會有回傳的結果.
#$result["status"],"true"代表執行正常,"false"代表執行失敗.
#$result["error"],錯誤訊息陣列.
#$result["function"],正在執行的函式
#$result["content"],編譯好的檔案位置.
#必填的參數:
#$conf["cppAddress"],字串,要編譯的cpp檔位置,請加上cpp副檔名.
$conf["cppAddress"]="externalT/compileCppThenDownload.cpp";
#可省略的參數:
#$conf["outputAddress"],字串,輸出的檔案位置與名稱,請加上附檔名,預設為".bin/cppOriFileName.bin".
#$conf["outputAddress"]="";
#$conf["noDownload"],字串,"true"為不要下載,改成回傳編譯好的檔案位置.
$conf["noDownload"]="true";
#備註:
#測試中...
var_dump(external::compileCppThenDownload($conf));
unset($conf);

*/

#提示目前執行的方法
echo "<hr>external::callShellMulti - testCase 1<p>";

/*

#涵式說明:
#呼叫shell執行系統命令,並取得回傳的內容.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["cmd"],執行的指令內容.
#$result["output"],爲執行完二元碼後的輸出陣列.
#必填的參數
#$conf["command"],字串陣列,要執行的指令與.
$conf["command"]=array("uname -a","ls","pwd","date");
#可省略參數:
#$conf["argu"],陣字串列,執行各個$conf["command"]時指令搭配的參數,預設為空陣列.
#$conf["argu"]=array(array(""));
#$conf["enablePrintDescription"],字串陣列,執行各個$conf["command"]時是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
#$conf["enablePrintDescription"]=array("false");
#$conf["printDescription"],字串陣列,執行各個$conf["command"]前要印出來的的文字,預設為$conf["command"]的內容,其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
#$conf["printDescription"]=array("");
#$conf["escapeshellarg"],字串陣列,執行各個$conf["command"]時是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false",其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
#$conf["escapeshellarg"]=array("false");
#備註:
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.
#參考資料:
#exec=>http://php.net/manual/en/function.exec.php
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
var_dump(external::callShellMulti($conf));
unset($conf);

*/

#提示目前執行的方法
echo "<hr>external::multiThreadsShell - testCase 1<p>";

/*

#涵式說明:
#運用nohup與&來達到雖依序執行但不等待前一個指令執行完再執行下一個指令,形成假多工的執行每個指令.
#回傳結果: 
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["cmd"],執行的指令內容.
#$result["output"],爲執行完二元碼後的輸出陣列.
#必填參數:
#$conf["command"],字串陣列,要執行的指令與.
$conf["command"]=array("php -r 'sleep(100);'","php -r 'sleep(100);'","php -r 'sleep(100);'","php -r 'sleep(100);'");
#$conf["fileArgu"],字串,變數__FILE__的內容.
$conf["fileArgu"]=__FILE__;             
#可省略參數:
#$conf["argu"],二維陣列字串,每個指令搭配的參數,預設為空陣列.
#$conf["argu"]=array(array());
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
#$conf["enablePrintDescription"]="true";
#$conf["printDescription"],字串陣列,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
#$conf["printDescription"]=array("");
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
$conf["escapeshellarg"]="false";
#$conf["username"],字串陣列,每個指令要用什麼使用者來執行,預設為執行php使用者,該參數不適用於apache環境.
#$conf["username"]=array("");
#$conf["password"],字串陣列,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
#$conf["password"]=array("");
var_dump(external::multiThreadsShell($conf));
unset($conf);

*/

#提示目前執行的方法
echo "<hr>external::callShellInBg - testCase 1<p>";

/*

#涵式說明:
#呼叫shell執行系統命令,並取得回傳的內容與pid.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["cmd"],執行的指令內容.
#$result["output"],爲執行完二元碼後的輸出陣列.
#必填的參數
#$conf["command"],字串,要執行的指令.
$conf["command"]="ls";
#$conf["fileArgu"],字串,變數__FILE__的內容.
$conf["fileArgu"]=__FILE__;             
#備註:
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,透過su使用root身份可能會被selinux阻擋.
#參考資料:
#http://php.net/manual/en/function.exec.php     
$callShellV2=external::callShellInBg($conf);
unset($conf);

#如果執行錯誤
if($callShellV2["status"]==="status"){
        
        #印出內容
        var_dump($callShellV2);
        
        #結束程式
        exit;
        
        }#if end

#反之
else{
        
        #印出內容
        var_dump($callShellV2);
        
        }#else end

*/      

#提示目前執行的方法
echo "<hr>external::callShellInBg - testCase 2<p>";

/*

#涵式說明:
#呼叫shell執行系統命令,並取得回傳的內容與pid.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["cmd"],執行的指令內容.
#$result["output"],爲執行完二元碼後的輸出陣列.
#必填的參數
#$conf["command"],字串,要執行的指令.
$conf["command"]="ping 127.0.0.1";
#$conf["fileArgu"],字串,變數__FILE__的內容.
$conf["fileArgu"]=__FILE__;             
#備註:
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,透過su使用root身份可能會被selinux阻擋.
#參考資料:
#http://php.net/manual/en/function.exec.php     
$callShellV2=external::callShellInBg($conf);
unset($conf);

#如果執行錯誤
if($callShellV2["status"]==="status"){
        
        #印出內容
        var_dump($callShellV2);
        
        #結束程式
        exit;
        
        }#if end

#反之
else{
        
        #印出內容
        var_dump($callShellV2);
        
        }#else end

*/      

#提示目前執行的方法
echo "<hr>external::killProcess - testCase 1<p>";

/*

#涵式說明:
#呼叫shell執行系統命令,中止執行中的pid.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["warning"],警告訊息陣列.
#$result["cmd"],執行的指令內容.
#$result["output"],爲執行完二元碼後的輸出陣列.
#$result["runing"],程式是否還在執行.
#必填的參數
#$conf["fileArgu"],字串,變數__FILE__的內容.
$conf["fileArgu"]=__FILE__;     
#$conf["pid"],字串,執行序的pid.
$conf["pid"]=$callShellV2["pid"];
#$conf["cmd"],字串,要中止的指令關鍵字.
$conf["cmd"]="ping 127.0.0.1";  
#備註:
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,透過su使用root身份可能會被selinux阻擋.
#參考資料:
#http://php.net/manual/en/function.exec.php
$killProcess=external::killProcess($conf);
unset($conf);

#如果執行錯誤
if($killProcess["status"]==="status"){
        
        #印出內容
        var_dump($killProcess);
        
        #結束程式
        exit;
        
        }#if end

#反之
else{
        
        #印出內容
        var_dump($killProcess);
        
        }#else end

*/

#提示目前執行的方法
echo "<hr>external::callShellExecInBg - testCase 1<p>";

/*

#涵式說明:
#呼叫shell_exec執行系統命令,並取得回傳儲存輸出內容的檔案與pid.
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.
#$result["cmd"],執行的指令內容.
#$result["fullCmd"],執行的完整指令
#$result["content"],爲執行完二元碼後的輸出陣列.
#$result["runing"],程式是否還在執行.
#$result["pid"],pid.
#必填的參數
#$conf["command"],字串,要執行的指令.
$conf["command"]="echo \"123\r\n456\r\n789\r\n\"";
#$conf["fileArgu"],字串,變數__FILE__的內容.
$conf["fileArgu"]=__FILE__;             
#備註:
#不是所有指令都能用apache的身份執行,目前已知java,javac,ping指令無法執行,透過su使用root身份可能會被selinux阻擋.
#參考資料:
#http://php.net/manual/en/function.exec.php     
$callShellExecInBg=external::callShellExecInBg($conf);
unset($conf);
        
#如果執行失敗
if($callShellExecInBg["status"]==="false"){
        
        #印出內容
        var_dump($callShellExecInBg);
        
        #結束程式
        exit;
        
        }#if end        
        
#反之
else{
        
        #印出內容
        var_dump($callShellExecInBg);
        
        }#else end
        
*/      

#提示目前執行的方法
echo "<hr>external::timeout - testCase 1<p>";
        
/*

#函式說明:
#檢查目標程式是否執行超過時間,將之中止. 
#回傳結果
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$result["function"],當前執行的函數名稱.       
#$result["timeout"],程序是否timeout,"true"代表是,"false"代表不是.
#必填參數:
#$conf["pid"],字串,程序的id.
$conf["pid"]="3972";
#$conf["cmd"],字串,程序的指令.
$conf["cmd"]="php test.php";
#$conf["fileArgu"],字串,__FILE__的內容,__FILE__的內容.
$conf["fileArgu"]=__FILE__;
#$conf["timeout"],整數,多少時間過後要timeout,單位為秒.
$conf["timeout"]=60;
$timeout=external::timeout($conf);
unset($conf);   
        
#如果處理timeout失敗
if($timeout["status"]==="false"){
        
        #印出內容
        var_dump($timeout);
        
        #結束執行
        exit;
        
        }#if end        

#印出內容
var_dump($timeout);     
        
*/
        
?>