1
exec('wget  --progress=bar  http://technabob.com/blog/wp-
content/uploads/2011/04/light_up_pi_symbol_1.jpg');

echo "1";

output   1

ie the download is not working.I m sure that the command is correct. I believe it has something to do with my Apache.Any help will be appreciated. The image is not getting downloaded.

I was wrong about Apache . I think it is about wget because I can run other commands on my server using

$output = `ls -al`;
echo "<pre>$output</pre>"; 
nickb
  • 59,313
  • 13
  • 108
  • 143
Shagun Sodhani
  • 3,535
  • 4
  • 30
  • 41

2 Answers2

1

This has nothing to do with Apache. Also, read the documentation for exec(). Most likely you'll see that that function call replaces the current process with the one specified in the argument, meaning that the rest of your code won't get run.

UPDATE

Perhaps the PATH is incorrect? Try using the full path to the wget command instead. Also, the current working directory will be used as the download destination for your command and the process may not have permissions to write to that directory.

noodl
  • 17,143
  • 3
  • 57
  • 55
  • So according to you download shld take palce and echo "1" should not – Shagun Sodhani Jun 16 '12 at 12:19
  • Excuse me, I've just looked up the PHP function and I'm wrong. It doesn't replace the current process (unlike in every other programming language). See `man 3 exec` for what that usually means. Go figure. – noodl Jun 16 '12 at 12:21
  • I have checked permission of a number of folders including /usr/bin. Could you pinpoint a few ones? – Shagun Sodhani Jun 16 '12 at 17:06
  • http://en.wikipedia.org/wiki/Unix_directory_structure .. you need to understand that your scripts run as a certain user. In general you can use /tmp for downloads but really you'd be better off using a network connection directly rather than forking a separate process (wget). I assume PHP can do this. – noodl Jun 16 '12 at 17:27
0

The mistake was that I didnot specify the download location so it was saved at some random location. But still the command was working right. The correct method could be $command="wget --output-document=/var/2 --progress=bar http:/"."/technabob.com/blog/wp-content/uploads/2011/04/light_up_pi_symbol_1.jpg";

Shagun Sodhani
  • 3,535
  • 4
  • 30
  • 41