Isaac
Isaac

Reputation: 625

php execute on specific host

I'm writing a shell script to be executed by php page. The page has to be on one server while the script runs on another. Both machines are on a shared file system. How do I specify the host name with the php execute command?

Upvotes: 0

Views: 38

Answers (1)

Andrew Sledge
Andrew Sledge

Reputation: 10351

You would need to use UNIX sockets, ssh, or some other way to connect to the other machine in order to execute it on that machine. PECL provides an ssh2 facility to do this.

$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$stream = ssh2_exec($connection, '/usr/local/bin/php -i');

Upvotes: 1

Related Questions