聞きたいこと
PHPでVPNサーバーに接続するためのコマンドを実行したいと思っているのですが、そのコマンドは対話形式で複数値を入力しないと接続できない仕様になっています。
proc_open関数を駆使して、対話形式で複数の値を入力して実行する処理を作成したのですが、うまく動作しません。
$desc = [["pipe", "w"], ["pipe", "w"], ["pipe", "w"], ["pipe", "w"], ["pipe", "w"]]; $handle = proc_open('/usr/local/vpnserver/vpncmd', $desc, $pipe); if (is_resource($handle)) { fwrite($pipe[0], "1"); fclose($pipe[0]); fwrite($pipe[1], env("SOFTETHER_IP")); fclose($pipe[1]); fwrite($pipe[2], $hubName); fclose($pipe[2]); fwrite($pipe[3], env("SOFTEHTER_SERVER_PASSWORD")); fclose($pipe[3]); fwrite($pipe[4], "SessionList"); $sessionList = stream_get_contents($pipe[4]); fclose($pipe[4]); return $sessionList; }
上記で実施したい内容のサマリを下にまとめると、
- SoftEtherというVPNサーバーに管理者モードで接続("1"を入力で管理者モード)
- どのVPNサーバーかIPアドレスを指定
- どの仮想HUBに接続するか指定
- 仮想HUBに接続してあるセッションの情報を取得
以上です。

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。