I
I
Ivan Vekov2017-05-02 17:56:55
PHP
Ivan Vekov, 2017-05-02 17:56:55

Exec() does not execute SFTP command, what is the reason?

From the console - it works, through exec () - no.

$pass = 'QQQQQ';
$server = '10.78.78.222';
$path = '/home/bitrix/www/test/file.txt';
exec('sshpass -p '.$pass.' sftp [email protected]'.$server.':'.$path.' '.$path, $D);
print_r($D);

What could be the reasons?
$D produces an incomprehensible "6".

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
anton_lazarev, 2017-05-02
@anton_lazarev

What's wrong with built-in functions?
php.net/manual/ru/function.ssh2-connect.php
php.net/manual/ru/function.ssh2-sftp.php

R
Roman Sokolov, 2017-05-02
@jimquery

Full paths to programs must be specified

$ whereis sftp
sftp: /usr/bin/sftp 
$ whereis sshpass
sshpass: /usr/bin/sshpass

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question