简体   繁体   中英

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 pat@myserver.com:/home/pat/file1.txt');

I get this error:

Disallowed system call: SYS_pipe

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

PHP环境不允许在您的服务器上执行exec。

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));
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM