6
我想用PHP腳本來運行siege命令並捕獲輸出。PHP shell_exec(),exec()和system()只返回部分輸出
運行在殼體下面提供了這些結果:
$ /usr/local/bin/siege -c30 -t30s -f urls.txt
.....
HTTP/1.1 200 0.10 secs: 11246 bytes ==> GET /*******.html
HTTP/1.1 200 0.11 secs: 11169 bytes ==> GET /*******.html
HTTP/1.1 200 0.10 secs: 11246 bytes ==> GET /*******.html
Lifting the server siege.. done.
Transactions: 1479 hits
Availability: 100.00 %
Elapsed time: 29.05 secs
Data transferred: 14.69 MB
Response time: 0.10 secs
Transaction rate: 50.91 trans/sec
Throughput: 0.51 MB/sec
Concurrency: 5.33
Successful transactions: 1479
Failed transactions: 0
Longest transaction: 0.16
Shortest transaction: 0.09
當經由EXEC在PHP運行相同的命令(),了shell_exec(),系統(),我只收到以下輸出。
HTTP/1.1 200 0.10 secs: 11246 bytes ==> GET /*******.html
HTTP/1.1 200 0.11 secs: 11169 bytes ==> GET /*******.html
HTTP/1.1 200 0.10 secs: 11246 bytes ==> GET /*******.html
因爲我真的只對siege提供的結果感興趣,所以這些數據對我來說毫無用處。由於某種原因,它忽略了圍困的結果。
下面是我在做什麼在PHP的例子...
exec('/usr/local/bin/siege -c30 -t30s -f urls.txt', $output);
+1:幹得好。明顯的東西,但只有當你已經知道應用程序可以輸出到任何一個流。手動操作終端並不是很清楚。 –
完美地工作。非常感謝!我可以使用以下命令獲得stderr輸出 '/ usr/local/bin/siege -c30 -t30s -f urls.txt 2>&1>/dev/null' 有沒有更好的方法來做這個? – theseanstewart