私は期待スクリプトを実行するphpスクリプトを持っています。scipt が telnet 経由で別のデバイスにリモート接続し、そこでいくつかのコマンドを実行して結果を返すことを期待します。PHP スクリプトは、リモート デバイスから返された結果を Web ページに出力するための手段にすぎません。
これは私が問題を抱えている行です:
stty rows 1000
コンソールからスクリプトを実行すると、すべてが正しく機能します。リモート デバイスは 1000 行 (stty 行で指定したもの) の出力を返します。Web ブラウザーからスクリプトを実行すると、stty 行で何を指定しても、15 行の出力が得られます。誰かが私が間違っていることを知っていますか?
念のため、私が使用しているスクリプトは次のとおりです。
script.php :
<?php echo shell_exec("/path/to/expect_scipt.exp"); ?>
expect_scipt.exp :
#!/usr/bin/expect
stty rows 1000
spawn telnet 10.0.0.1
expect "login:"
send "admin\n"
expect "assword:"
send "admin\n"
expect ">"
send "en\n"
expect "assword:"
send "admin\n"
expect "#"
send "show cable modem\n"
expect "#"
exit
それらをテストするために私が行うことは次のとおりです。
これをコンソールで実行します:
#su apache
$php script.php
...1000 lines of output...
Web ブラウザーを開き、script.php に移動します。
...15 lines of output...
前もって感謝します。