开发者

Permissions issue when using PHP system and cURL?

I'm trying to create a php script that will put a file on a remote server.

The following line will work from the CLI:

curl -u username:pass -T myfile.jpg sftp://my.domain.com/dir/

However, if I take this into PHP and try to run it through 'system' like:

<? system('curl -u username:pass -T myfile.jpg sftp://my.domain.com/dir/'); ?>

I get an error:

curl: (7) Failed to connect to xxx.xxx.xx.xx: Permission denied

Also, to complicate things, this is going from a RHEL to a Windows Server. Anyone have a suggestion or a fix?

Below is the result from the PHP cURL library.

* About to connect() to my.domain.com port 22 (#0)
*   Trying xxx.xxx.xx.xx... * connected
* Connected to my.domain.com (xxx.xxx.xx.xx) port 22 (#0)
* SSH authentication methods available: publickey,password
* Initialized password authe开发者_JAVA技巧ntication
* Authentication complete
* Upload failed: Permission denied (3/-31)
* Connection #0 to host my.domain.com left intact
* Closing connection #0


PHP has it's own cURL library that you should probably use. php cURL


Your problem is that system() doesn't allow curl to ask you for a password.

Consider other authentication methods.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜