View Single Post

  #1 (permalink)  
Old 10-23-2007, 07:44 PM
vivekv vivekv is offline
Junior Member
User
 
Join Date: Sep 2007
My distro: CentOS
Posts: 16
Rep Power: 0
vivekv is on a distinguished road
Default Shell script to perform operation on remote server

Hello

I have a backup server. And I want to do this following operation

1. ssh to that backup server (the remote server is already paired with my server,so no password entering screen)
2. fetch www.abc.com/file.zip
3. scp file.zip root@myserver.com:/home/user/www/file.zip


Its not joke, I know I can do this operation with wget. But its not what I want.

Because, The remote backup server only allows FTP and SSH access.
There is no http access( the server is rsyncpalace.com)


So, I have coded like this


<?php
$command="ssh user@backupserver.com"; // demo server
$output=shell_exec($command);

$command="fetch http://definitions.symantec.com/defs/20071022-017-v5i32.exe";
$output=shell_exec($command); // Sample file

$command="scp user@myserver.com:/home/user/www/20071022-017-v5i32.exe";
$output=shell_exec($command); // Sample file


print "<pre>$output</pre>\n"; //show output
?>


But It did not work.


Can anyone please let me know how to do this work?

I want php code. not pure shell code.

Not sure, how .cgi file will work , no idea

Please help me
Thanks
Reply With Quote