473,406 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

PHP and WGET generate 0 byte files

I have a problem with PHP where wget generates 0 byte files. Below
is
the code that I use.

// ********************
$savedir = "/webroot/vifs/app/webroot/static/1234567890";
$url = "http://www.google.com";
$test = mkdir( $savedir, 0777);
exec("/usr/bin/wget -nH -nd -d -P$savedir $url");
// ********************
What I have noticed is that if the directory already exists, WGET
works fine. But if the directory is created prior to, as shown in
the
code, WGET generates a file of 0 bytes.
MKDIR always returns successfully.
I've tried inserting a SLEEP(5) after MKDIR and that does not help.
Would anyone know why this is happening?
Thanks

Nov 7 '07 #1
2 3524
On Nov 7, 3:12 pm, Don69 <vaillancourt....@gmail.comwrote:
I have a problem with PHP where wget generates 0 byte files. Below
is
the code that I use.

// ********************
$savedir = "/webroot/vifs/app/webroot/static/1234567890";
$url = "http://www.google.com";

$test = mkdir( $savedir, 0777);

exec("/usr/bin/wget -nH -nd -d -P$savedir $url");
// ********************

What I have noticed is that if the directory already exists, WGET
works fine. But if the directory is created prior to, as shown in
the
code, WGET generates a file of 0 bytes.

MKDIR always returns successfully.

I've tried inserting a SLEEP(5) after MKDIR and that does not help.

Would anyone know why this is happening?

Is safe mode on? I once had a problem with PHP not writing to a
directory that had been chmoded 0777. Turned out the problem was safe
mode. I turned it off and then things worked fine.

However, that is a long shot. My first guess is that this is more of a
wget issue than a PHP issue.


Nov 8 '07 #2
On Nov 8, 3:12 am, Don69 <vaillancourt....@gmail.comwrote:
I have a problem with PHP where wget generates 0 byte files. Below
is
the code that I use.

// ********************
$savedir = "/webroot/vifs/app/webroot/static/1234567890";
$url = "http://www.google.com";

$test = mkdir( $savedir, 0777);

exec("/usr/bin/wget -nH -nd -d -P$savedir $url");
// ********************

What I have noticed is that if the directory already exists, WGET
works fine. But if the directory is created prior to, as shown in
the
code, WGET generates a file of 0 bytes.

MKDIR always returns successfully.

I've tried inserting a SLEEP(5) after MKDIR and that does not help.

Would anyone know why this is happening?

Thanks
-P$savedir =-P $savedir

Nov 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Martin | last post by:
I have a PHP script that should be run a few times a day. Currently I run this script manually as I haven't been able to set up Lynx or wget to run it as a cronjob. Or to be more specific: the...
1
by: LRW | last post by:
In a PHP script I have the following two lines: $thumbproc = escapeshellcmd("wget -q -T 2000 http://(A URL)/pa-thumbs/createthumbs.php?dir=".$order_po." &"); exec("$thumbproc 2>&1", $output); ...
7
by: Ken | last post by:
How do I call c:\wget\wget.exe from a php or html file? so I can use php variables to define the file names to download. I want to set up wget to download several files from a server to my hard...
2
by: Robert P. J. Day | last post by:
just getting started with python, and i'm designing a program for fetching software from the net, given the package name, version number and/or date stamp, download method (tarball, CVS, etc.) and...
2
by: Google Mike | last post by:
I have an RH9 Linux PHP 4.2.2 web page that I need to call a Bash file under the context of root and do the wget command to download a file, clobbering the previous download of this same filename....
4
by: Stephen | last post by:
I need to generate input XML for another application by serialising classes defined in an XSD document. The code below will generate the XML I require but I need to generate this in memory rather...
7
by: petr pilsl | last post by:
sorry - no idea where to post my question, so I crossposted to a linux and a html-authoring-group. Both groups might be familiar with wget. wget -p http://www.goldfisch.at does not load the...
0
by: David Hauser | last post by:
Hi all I have a aspx page that should generate a zip file from a couple of files. I tried the following code, but something doesn't work correctly, although no error message appears and the...
3
by: Jesse | last post by:
Hi all, I have a problem using wget and Popen. I hope someone can help. -- Problem -- I want to use the command: wget -nv -O "dir/cpan.txt" "http://search.cpan.org" and capture all it's...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.