简体   繁体   English

用户phpseclib0.3.1-sftp get-当我将本地文件留空时,我没有得到正确的文件内容

[英]User phpseclib0.3.1 - sftp get - When I leave local file blank, I don't get correct content of file

If I use a local filename, the filename is properly copied, however, if you leave local filename empty, you are supposed to receive the content of the file. 如果我使用本地文件名,则文件名会被正确复制,但是,如果您将本地文件名保留为空,则应该接收文件的内容。

Example code: 示例代码:

$stat = $sftp->get('xmlfile.cml','xmlfile.xml'); $ stat = $ sftp-> get('xmlfile.cml','xmlfile.xml'); print "$stat 打印“ $ stat
"; “;

(This works fine) (这很好)

$xmlcontent = $sftp->get('cp1301080801_status.xml'); $ xmlcontent = $ sftp-> get('cp1301080801_status.xml'); print "Content of file = $xmlcontent<>"; 打印“文件内容= $ xmlcontent <>”;

*(This prints what looks more like the stat of the file instead of the content. It starts with the date (which is the modofoed timestamp of file, followed by some numbers and the name of the web server repeated about 10 times with a number after it that increases each time - like maybe a port number or byte offset) * *(这会打印出看起来更像文件的统计信息,而不是内容。它以日期开头(这是文件的修改时间戳,后跟一些数字,并且Web服务器的名称重复了大约10次,并带有一个数字)之后每次增加-例如端口号或字节偏移量)*

It would make things easier if I didn't have to fopen the local file after the transfer. 如果我在传输后不必打开本地文件,那将使事情变得更加容易。 Anyone have an idea what is going on here? 有人知道这里发生了什么吗?

Can you post a copy of the logs? 您可以发布日志副本吗? Here's an example of how to get them: 这是如何获取它们的示例:

http://phpseclib.sourceforge.net/ssh/examples.html#logging http://phpseclib.sourceforge.net/ssh/examples.html#logging

Note the define() and the $ssh->getLog() stuff. 注意define()和$ ssh-> getLog()东西。

As for the specific problem you're having... what does print "$stat" do? 至于您遇到的特定问题...打印“ $ stat”会做什么? It should print "1". 它应该打印“ 1”。

Also, fwiw, you're opening two different files in your example. 同样,首先,您将在示例中打开两个不同的文件。 My best guess, atm, is that you're thinking you're opening the same files and expecting the content to be the same when in fact they should be different and that what you're getting with both of the $sftp->get()'s is, in fact, correct. 我最好的猜测是atm,您实际上是在想打开相同的文件,并希望内容相同,而实际上它们应该是不同的,并且您通过$ sftp-> get获得的内容都是相同的()实际上是正确的。

The logs will tell us for sure. 日志肯定会告诉我们。

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

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