shell - can't download file using wget with authentication while being called from php -


i've created small remote download script downloads remote files server using wget. here's how works: have html form, user can enter url, destination file name, , optionally username , password authenticate, in case needed. form calls php script, using ajax, , php script passes information shell script. problem is, shell script works flawlessly on local linux machine, on server, doesn't work authentication(without authentication, works fine.)

#!/bin/bash  if test $# -eq 2     wget -o "$2" $1 elif test $# -eq 4     wget -o "$2" --http-user="$3" --http-password="$4" $1 else     wget $1 fi 

it might worth mentioning that, own shared server.

thanks

edit: possible version of wget installed on server, doesn't support http authentications???

edit 2: piped output of wget file this:

wget -o "$2" --http-user="$3" --http-password="$4" $1 | echo >> output 

but output empty, i.e. no messages being printed wget!!! , did too, check if credentials passed ok:

echo "$3 | $4" >> credentials 

and ok.

and php code runs shell script:

if(isset($_post["startdownload"])) {     list($url, $dest, $user, $pass) = explode("|", urldecode($_post["data"]));     $filelen = file_len($url);     $freespace = getremainingspace();     //die( "( free: $freespace, file: $filelen )" );     if($filelen > $freespace - 10000)     {         $result = json_encode(array("error" => true,                          "message" => "there not enough space download file. ( free: $freespace, file: $filelen )"));         die($result);     }     else     {             if($user != "null" && $pass != "null")             {                 execinbackground("../dl.sh '{$url}' '../{$dest}' '{$user}' '{$pass}'| @ now");             }             else             {         execinbackground("../dl.sh '{$url}' '../{$dest}' | @ now");                 }             $result = json_encode(array("error" => false, "message" => "starting download..."));             die($result);     } } function execinbackground($cmd)  {     if (substr(php_uname(), 0, 7) == "windows"){         pclose(popen("start /b ". $cmd, "r"));      }     else {         exec($cmd . " > /dev/null &");       } }  

well, running script via system/exec/shell_exec or others, going "block" rest of php script anyway. answer, check out this: http://www.zarafa.com/wiki/index.php/using_wget_and_http_authentication_for_supported_downloads

wget -o "$2" --user="$3" --ask-password="$4" $1 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -