god hates me
[configmanager.git] / lib / screenos.plugin.php
index 20555d3..1cf4914 100644 (file)
@@ -20,4 +20,43 @@ function nsos_getConfig($host, $username, $password, $enable)
 {
        return genericssh_ssh($host, $username, $password, "cli show configuration");
 }
+
+// remembver this:
+function screenosisgay($host, $username, $password, $command)
+{
+        $connector = ssh2_connect("$host");
+        error_log("attempting connect to $host with $username");
+        if($connector) {
+                error_log("connector true");
+        } else {
+                error_log("connector false");
+        }
+        ssh2_auth_password($connector, "$username", "$password");
+        $stream = ssh2_shell($connector, 'ansi');
+        fwrite($stream, PHP_EOL);
+        fwrite($stream, "set console page 0".PHP_EOL);
+        fwrite($stream, "get config".PHP_EOL);
+        fwrite($stream, PHP_EOL);
+        sleep(1);
+        stream_set_blocking($stream, true);
+        //fwrite($stream, "exit".PHP_EOL);
+        //fwrite($stream, "n".PHP_EOL);
+
+
+        $config = "";
+        $initline = "";
+        $haveinit = false;
+        while($buf = fgets($stream, 4096)) {
+                flush();
+                echo "got buf\n\"$buf\"\n";
+                $initline = $buf;
+                $config .= $buf;
+        }
+        fclose($stream);
+
+        return $config;
+}
+
+
+
 ?>
\ No newline at end of file