Bit of an interesting one for all you php'ers out there

Soldato
Joined
30 Jun 2003
Posts
2,807
Location
Berkshire
Currently writing a script which uses php and ssh2. It connects to the server and runs the command. What i want it to do is output the command in the browser window, can this be done?

Current test code is

Code:
<?php
$connection = ssh2_connect('REMOVED', 22);
ssh2_auth_password($connection, 'root', 'REMOVED');

$stream = ssh2_exec($connection, ' cd / ; wget ftp://REMOVED/fedora9/RPM-GPG-KEY');
stream_set_blocking($stream, true);

$output = stream_get_contents($stream);

?>
 
yep already thought of that, the script works fine, what im wanting if possible is to display the output of when the command is run.
 
Code:
if($output){
echo $output;
}
:confused:

So you want to stream_get_contents($stream); to be displayed?
 
When you echo $output you get nothing?

Code:
<?php

$connection = ssh2_connect('REMOVED', 22);
ssh2_auth_password($connection, 'root', 'REMOVED');

$stream = ssh2_exec($connection, ' cd / ; wget ftp://REMOVED/fedora9/RPM-GPG-KEY');
stream_set_blocking($stream, true);

$output = stream_get_contents($stream);
echo $output;

?>
This should display stream_get_contents($stream); if not then something else is wrong, afaik.
 
yep that's correct, the script is executing and it's downloading the file correctly just not showing any output that it's currently running.
 
Back
Top Bottom