bash - running scp script from exec function - PHP -


i trying scp file 1 server external mailserver.

in code use:

exec('/full/path/to/script.sh' '/full/path/to/file_to_transfer.txt'); 

in script.sh have:

scp  -i /full/path/to/private.key $1 [user]@[ip]:/opt/mailman/mailman-bundler/venv-3.4/lib/python3.4/site-packages/mailman/templates/en/. 

when call script file via cli, script runs fine , file transfers. when run in php apache/www-data user exec() call fails code: 126 - translates to: "command invoked cannot execute".

extra notes:

i noticed first time every user tries this, confirmation of rsa fingerprint. thought script stalling on , problem. manually went in www-data user , confirmed fingerprint. problem still exists.

after many tries, created replica set of folders, scripts , files , opened permissions - way down root see if had wrong permissions set. still receive 126 error.

my project manager against using idea of using php ssh2/scp functions (ex: http://php.net/manual/en/function.ssh2-scp-send.php) reason if fundamental bash script failing, fail same reasons ssh2/scp functions well.

i have hunch ^ wrong idea because script works via cli , not via apache, while php scp functions meant run apache.

any insight on problem (calling scp inside script exec() call) stems or hard evidence php scp functions work appreciated.

let me know if there more information provide me out. thanks.

i published project allows php obtain , interact real bash shell. here: https://github.com/merlinthemagic/mts

after downloading use following code:

//if script not require root permissions can change //second argument on getshell() false. return bash shell //with permissions www-data or apache user.  $shell    = \mts\factories::getdevices()->getlocalhost()->getshell('bash', true); $return1  = $shell->execmd('/full/path/to/script.sh' '/full/path/to/file_to_transfer.txt'); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -