execute command line from php over server windows 2003

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I try to execute command remote  whit php oser server windows , but not
work

any sugestions

thanks



<?php
error_reporting(E_ALL);
if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't
exist");
// log in at server1.example.com on port 22



if(!($con = ssh2_connect("192.168.17.134", 22))){
    echo "fail: unable to establish connection\n";
} else {
    // try to authenticate with username root, password secretpassword
    if(!ssh2_auth_password($con, "juan", "juan01")) {
        echo "fail: unable to authenticate\n";
    } else {
        // allright, we're in!
        echo "okay: logged in...\n";

        // create a shell
         echo ssh2_exec($con,'cmd dir');

         echo "check dir...\n";

        if(!($shell = ssh2_shell($con, 'vt102', null, 80, 40,
SSH2_TERM_UNIT_CHARS))){
            echo "fail: unable to establish shell\n";
        } else{
            echo "open shell...\n";
            stream_set_blocking( $shell, true );
            // send a command
            fwrite($shell,"dir \n");
            sleep(1);

            // & collect returning data
            $data = "";
            while( $buf = fread($shell,4096) ){
                $data .= $buf;
            }
            fclose($shell);
        echo "end shell ...\n";
        }
    }
}
?>


[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux