私はbashとPerlスクリプトのコレクションを持っています
- Linux ボックスへの展開に必要なディレクトリ構造を開発する
- (オプション) svn からコードをエクスポート
- このソースからパッケージをビルドする
これは端末からうまく機能しています。現在、クライアントはこのプロセスへの Web インターフェイスを要求しています。
たとえば、特定のページの [Create New Package] ボタンは、上記の手順を 1 つずつ呼び出し、スクリプト全体が実行されたときではなく、スクリプト エコーとして出力をユーザーに返します。
プログラム実行機能(システム、実行、パススルー...またはこのプロセスフローに適合するもの)を介してそれを呼び出したbashスクリプトからWebページまたはphpスクリプトに瞬時の出力を送信することは可能ですか?
なぜこれを行うのがエレガントですか?
そのようなことをしている間、どのようなセキュリティ対策を講じるべきですか (可能な場合)?
編集 いくつかの検索の後、ソリューションの一部を見つけましたが、まだ機能していません:
$cmd = 'cat ./password.txt|sudo -S ./setup.sh ';
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will read from
);
flush();
$process = proc_open($cmd, $descriptorspec, $pipes, './', array());
echo "<pre>";
if (is_resource($process)) {
while ($s = fgets($pipes[1])) {
print "Message:".$s;
flush();
}
while ($s = fgets($pipes[2])) {
print "Error:".$s;
flush();
}
}
echo "</pre>";
出力: (ウェブページ)
Error:WARNING: Improper use of the sudo command could lead to data loss
Error:or the deletion of important system files. Please double-check your
Error:typing when using sudo. Type "man sudo" for more information.
Error:
Error:To proceed, enter your password, or type Ctrl-C to abort.
Error:
Error:Password:
Error:Sorry, try again.
Error:Password:
Error:Sorry, try again.
Error:Password:
Error:Sorry, try again.
Error:sudo: 3 incorrect password attempts**
私が今抱えている最初の問題は、sudoパスワードを渡すことです
助けてください !