herghost Posted January 9, 2012 Share Posted January 9, 2012 Hi all I am pulling my hair out trying to get the following script to work <?php error_reporting(E_ALL); ini_set('display_errors', '1'); 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("*.*.*.*", 22))){ echo "fail: unable to establish connection\n"; } else { // try to authenticate with username root, password secretpassword if(!ssh2_auth_password($con, "root", "********")) { echo "fail: unable to authenticate\n"; } else { // allright, we're in! echo "okay: logged in...\n"; // execute a command if (!($stream = ssh2_exec($con, "ls -al" ))) { echo "fail: unable to execute command\n"; } else { echo "should be ok"; // collect returning data from command stream_set_blocking($stream, true); $data = "path to file checked by logging into WINSCP and looking at properties. Is a .txt file"; echo $data; while ($buf = fread($stream,4096)) { $data .= $buf; } fclose($stream); } } } Basically shouldnt this display the contents of the file to me? On screen I just get okay: logged in... should be ok What is my error? Thanks Link to comment https://forums.phpfreaks.com/topic/254687-php-sftp-problem-with-fread/ Share on other sites More sharing options...
Muddy_Funster Posted January 10, 2012 Share Posted January 10, 2012 even this fails to display? $data = "path to file checked by logging into WINSCP and looking at properties. Is a .txt file"; echo $data; Link to comment https://forums.phpfreaks.com/topic/254687-php-sftp-problem-with-fread/#findComment-1306140 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.