PHP Classes

File: example.php

Recommend this page to a friend!
  Packages 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: 19 years ago
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; }

?>