cristalmolix Posted March 12, 2010 Share Posted March 12, 2010 hello guys i have a .bat file it goes liek this ssh nadeemsh@nadeemshafi.co.uk 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 Quote Link to comment https://forums.phpfreaks.com/topic/195055-bat-file-get-and-enter-password/ Share on other sites More sharing options...
trq Posted March 12, 2010 Share Posted March 12, 2010 You need to setup keys for ssh. Quote Link to comment https://forums.phpfreaks.com/topic/195055-bat-file-get-and-enter-password/#findComment-1025359 Share on other sites More sharing options...
cristalmolix Posted March 12, 2010 Author Share Posted March 12, 2010 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; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/195055-bat-file-get-and-enter-password/#findComment-1025362 Share on other sites More sharing options...
cristalmolix Posted March 12, 2010 Author Share Posted March 12, 2010 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/195055-bat-file-get-and-enter-password/#findComment-1025365 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.