Brian Glaz
Brian Glaz

Reputation: 15696

Alternative to ftp_exec()?

Is there any way to have one server call and execute a script on another server? I have tried ftp_exec(), but the server does not support it. Here is what I am trying to do.

Server 1 creates and uploads a zip file to Server 2. Server 2 then unzips and extracts the file.

Currently I have scheduled cron jobs at alternating times, one on each server in order to do this. Ideally I would like Server 1 to be able to do everything, sending a message to sever 2 telling it to unzip and extract the uploaded file.

Is it possible to do something on Server 1, like exec(php ftp://user:password@server2/unzip.php) ?

Is it maybe possible using CURL?

Upvotes: 2

Views: 1145

Answers (2)

Marc B
Marc B

Reputation: 360872

FTP = File Transfer Protocol. It's not intended (and should never be used for) remote execution. If you need to trigger a remote script, use HTTP. It's easy enough to do

$stat = file_get_contents('http://example.com/unzip.php');

to invoke the remote PHP script to do the unzipping. If you need authentication on the URL, you can set up a stream or use CURL instead.

Upvotes: 3

xdazz
xdazz

Reputation: 160963

Does your sever support ssh or have you the ssh account?

You can run remote commands via ssh.

Upvotes: 1

Related Questions