<?php exit; // To test the class from the command line we need a shell with no control // terminal to avoid SSH from prompting interactively for the password: // run this with ' ssh -x -T localhost "(cd `pwd` ; php ssh_test.php)" ' // To test on the web, just invoke this script. $debug_sexec = TRUE; require_once 'ssh.php'; $remote = "*****@*****.**"; $password = "******"; echo "<pre>\n"; $rmt = new SExec($remote, $password); if ($rmt == FALSE) { echo "Couldn't open the connection\n"; exit; } echo "Created\n"; $debug_copy_to = TRUE; if (isset($debug_copy_to)) { echo "\nCopy ldir ./test.txt to rdir {$remote}:k/.\n"; $rmt->ssh_copy_to("./test.txt", "k", $out); } $rmt->destruct(); echo "</pre>\n\n"; exit;
$rmt->ssh_passthru("ls", $status = 0); echo "\nExit status was {$status}"; } #$debug_exec = TRUE; if (isset($debug_exec)) { $rmt->ssh_exec("ls", $out = ""); # $rmt->ssh_exec("ls"); print_r($out); foreach ($out as $line) { echo $line . "\n"; } } #$debug_copy_to = TRUE; if (isset($debug_copy_to)) { echo "\nCopy ldir ./CVS to rdir {$remote}:k/.\n"; $rmt->ssh_copy_to("./CVS", "k", $out); echo "\nCopy lfile ./CVS/Entries to rdir {$remote}:k/.\n"; $rmt->ssh_copy_to("./CVS/Entries", "k", $out); echo "\nCopy ldir ./CVS to rfile {$remote}:k/p\n"; $rmt->ssh_copy_to("./CVS", "k/p", $out); echo "\nCopy lfile ./CVS/Entries to rfile {$remote}:k/p\n"; $rmt->ssh_copy_to("./CVS/Entries", "k/p", $out); } #$debug_copy_from = TRUE; if (isset($debug_copy_from)) { echo "\nCopy rdir ./k/CVS to ldir k/.\n"; $rmt->ssh_copy_from("./k/CVS", "k", $out); echo "\nCopy rfile ./k/CVS/Entries to ldir k/.\n"; $rmt->ssh_copy_from("./k/CVS/Entries", "k", $out); echo "\nCopy rdir ./k/CVS to lfile k/p\n"; $rmt->ssh_copy_from("./k/CVS", "k/p", $out);