简体   繁体   English

PHP ssh2_scp_send用单引号引起来的远程文件名

[英]PHP ssh2_scp_send remote file name enclosed in single quotes

I'm writing a code to SCP a file from Solaris 10 machine to a router (couldn't be simpler). 我正在将代码从Solaris 10计算机写入文件SCP到路由器(再简单不过了)。 Here is the code: 这是代码:

<?php
$src = "test.txt";
$trg = "test.txt";

echo "Connecting...\n";
$connection = ssh2_connect('myrouter',22);

echo "Authenticating...\n";
ssh2_auth_password($connection, 'mylogin', 'mypassword');

echo "Sending...\n";
ssh2_scp_send($connection, $src, $trg);
?>

This works just fine but the remote filename is screwed up: 这很好用,但是远程文件名搞砸了:

10/11/2012  10:57p                  15 'test.txt'

Note the single quotes around the file name test.txt . 注意文件名test.txt的单引号。

When I use Solaris SCP everything works fine. 当我使用Solaris SCP时,一切正常。 Here is the command: 这是命令:

solaris10$ scp test.txt mylogin@myrouter:test.txt

The remote file name looks like: 远程文件名如下所示:

10/11/2012  11:10p                  15 test.txt

So the problem seems to be limited to PHP. 因此,问题似乎仅限于PHP。

Did anybody have similar issue? 有人有类似的问题吗? Where should I start looking? 我应该从哪里开始寻找?

The remote filesystem is FAT32. 远程文件系统是FAT32。

Thank You, PN. 谢谢,PN。

The bottom comment on this page http://www.php.net/manual/en/function.ssh2-scp-send.php refers to a problem you might be having; 本页底部的注释http://www.php.net/manual/zh/function.ssh2-scp-send.php指的是您可能遇到的问题。

Can you set $trg to the full remote server path? 您可以将$trg设置$trg完整的远程服务器路径吗?

$trg = "/var/www/test.txt";

or 要么

$trg = "/test.txt";

I had the same problem when using ssh2_scp_send(). 使用ssh2_scp_send()时,我遇到了同样的问题。 However, I switched to using ssh2_sftp() and fwrite() and the problem went away. 但是,我改用ssh2_sftp()和fwrite(),问题消失了。 See examples in the comments on the http://www.php.net/manual/en/function.ssh2-sftp.php page. 请参阅http://www.php.net/manual/zh/function.ssh2-sftp.php页面上的注释示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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