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

会有一股神秘感。 提交于 2021-01-26 20:01:50

问题


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?


回答1:


PHP environment does not allow exec on your server.




回答2:


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


来源:https://stackoverflow.com/questions/7826755/php-exec-scp-does-not-copy-the-file-to-the-remote-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!