Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of stieven kalengkian  >  Shell2  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example file
Class: Shell2
Access remote server resources using secure shell
Author: By
Last change:
Date: 2007-08-13 01:47
Size: 731 bytes
 

Contents

Class file image Download
<?php
$host 
"127.0.0.1";
$user "foo";
$pass "bar";

$localFile="/home/test1.txt";
$remoteFile="/home/test2.txt";

include 
"class.shell2.php";

$ssh = new shell2;
if (
$ssh->login($host,$user,$pass)) {

    
//SSH Command
    
$ssh->cmd("ls -la");
    echo 
$ssh->output();

    
//SFTP Send/Upload to remote server
    //$ssh->send(localFile,remoteFile,filePermission)
    
if ($ssh->send($localFile,$remoteFile,0755)) {
            echo 
"File has been uploaded\n";
    } else { echo 
$ssh->error; }

    
//SFTP Get/Download from remote server
    
if ($ssh->get($remoteFile,$localFile)) {
            echo 
"File has been downloaded\n";
    } else { echo 
$ssh->error; }

} else { echo 
$ssh->error; }

?>