Pat R Ellery
Pat R Ellery

Reputation: 1716

PHP Exec SCP does not copy the file to the remote server

I need a file from a server to another server (I own both) using PHP. I have the following script:

<?php

exec('scp /home/pat/file1.tst [email protected]:/home/pat/file1.txt');

I get this error:

Disallowed system call: SYS_pipe

What is that error? and how can I fix it?

Upvotes: 13

Views: 8007

Answers (2)

user1469439
user1469439

Reputation:

This is kinda late, I know, but you might have better luck with phpseclib's pure PHP SCP implementation:

https://raw.github.com/phpseclib/phpseclib/master/phpseclib/Net/SCP.php

Example of how to use it:

<?php
include('Net/SCP.php');
include('Net/SSH2.php');

$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
    exit('bad login');
}

$scp = new Net_SCP($ssh);
$scp->put('abcd', str_repeat('x', 1024*1024));
?>

Upvotes: 2

TigOldBitties
TigOldBitties

Reputation: 1337

PHP environment does not allow exec on your server.

Upvotes: 12

Related Questions