Forum Moderators: coopster
I got as far as
exec('gunzip -f GeoIP.dat.gz', $ret); I'm not used to working with file ops so I'm stuck. Did search but couldn't find anything helpful.
PHP 4.something on Linux and Apache.
Help?
exec('gunzip -f -v GeoIP.dat.gz', $ret);
foreach($ret as $line) {
echo $line;
echo "<br />";
}
Both the .gz and the old .dat files are in the same directory. It makes no difference if the old .dat is gone.
gunzip is there though and runs, if I run it with a bogus flag for instance, I get the help summary as output.
Ok, if downloading and decompressing the file is all you want to do then maybe we can skip PHP altogether.
This command will download the file with wget and decompress it with gzip and write it to a file:
wget -q http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz -O- ¦ gzip -d - > GeoIP.dat You may not have wget available depending on what distribution of linux you are using, in that case you can use curl or lynx instead.
Andrew
But one reason I wanted this set up in PHP is incase I want to add any logic to it later. I also don't have direct access to the console, so I wanted to get them to set up a cron and then I know I can edit the PHP any time I feel like it.
Can that command line above be exec'ed in PHP?
array(0) {
}
int(126)
array(11) {
[0]=>
string(10) "gzip 1.3.5"
[1]=>
string(12) "(2002-09-30)"
[2]=>
string(39) "Copyright 2002 Free Software Foundation"
[3]=>
string(36) "Copyright 1992-1993 Jean-loup Gailly"
[4]=>
string(47) "This program comes with ABSOLUTELY NO WARRANTY."
[5]=>
string(43) "You may redistribute copies of this program"
[6]=>
string(50) "under the terms of the GNU General Public License."
[7]=>
string(69) "For more information about these matters, see the file named COPYING."
[8]=>
string(20) "Compilation options:"
[9]=>
string(83) "DIRENT UTIME STDC_HEADERS HAVE_UNISTD_H HAVE_MEMORY_H HAVE_STRING_H HAVE_LSTAT ASMV"
[10]=>
string(28) "Written by Jean-loup Gailly."
}
int(0)