Jump to content

.bat file get and enter password


Recommended Posts

hello guys

 

i have a .bat file

 

it goes liek this

 

ssh [email protected] test.dat

exit;

 

 

teh ssh without public key asks for a password i dont want to do this manualy so how do i get it to enter the password, the command ssh doesent take teh password in

 

i know i can read files in dos or wotever

 

but how do i know when to enter it and tell it to enter it when ssh asks for it ??

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/195055-bat-file-get-and-enter-password/
Share on other sites

do i have to setup the keys or can i somehow feed the password into the prompt from the php script or the batch file ? im using proc_open so i can feed stuff in to the pipe

 

<?php
public function indexAction()
    {
        echo "1";
        $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("file", "C:\\error-output.txt", "a") // stderr is a file to write to
        );
        echo "2";
        $cwd = 'C:\\';
        $env = array('some_option' => 'aeiou');
        echo "3";
        $process = proc_open('start c:\\test.bat', $descriptorspec, $pipes);
        sleep(10);
        echo "4";
        if (is_resource($process)) {
            // $pipes now looks like this:
            // 0 => writeable handle connected to child stdin
            // 1 => readable handle connected to child stdout
            // Any error output will be appended to /tmp/error-output.txt
                echo "5";
            fwrite($pipes[0], '<?php print_r($_ENV); ?>');
            fflush($pipes[0]);
            fclose($pipes[0]);
                echo "6";
            echo stream_get_contents($pipes[1]);
            fclose($pipes[1]);
            echo "7";
            // It is important that you close any pipes before calling
            // proc_close in order to avoid a deadlock
            $return_value = proc_close($process);
            echo "8";
            echo "command returned $return_value\n";
                echo "9";
        }
        echo "10";
        exit;

    }
?>

after i enter teh password HOWEVER ITS DONE, lets say SSH KEYS are not setup,

 

if for instance i get an error saying "this server dosent allow shell connections"

 

how do i get that to the screen,

 

the above script seems to output DIR etc etc to teh browser screen

 

but wont output the result of teh ssh command

 

whats the difference ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.