Problem in wget in php script
Moderator: General Moderators
-
abhijeetgk
- Forum Newbie
- Posts: 9
- Joined: Thu Oct 18, 2007 11:33 pm
- Location: Mumbai
- Contact:
Problem in wget in php script
hi
in my application there is one section of code where i m trying to get the content via "wget" command.
for normal wget command on unix prompt it is working properly ie "wget http://domainname.com/path_to_file"
but for the script it is giving me error of unable to resolve host name.
is this the problem of linux server of code.
please guide me on the same
thanks in advance
in my application there is one section of code where i m trying to get the content via "wget" command.
for normal wget command on unix prompt it is working properly ie "wget http://domainname.com/path_to_file"
but for the script it is giving me error of unable to resolve host name.
is this the problem of linux server of code.
please guide me on the same
thanks in advance
-
abhijeetgk
- Forum Newbie
- Posts: 9
- Joined: Thu Oct 18, 2007 11:33 pm
- Location: Mumbai
- Contact:
it is correct
hi
the domain name is correct
for the same domain name i can get the same content in browser correctly
Some more details of the problem are as-
In the application i m passing some parameters along with the url and depending on that parameters i m generating one output file
the contents of that file is mailed to user.
The contents of the url along with the parameters were generating correctly in browser but when i m trying to get that output in one file to mail the user then the output file is showing 0 k ie no content.
the domain name is correct
for the same domain name i can get the same content in browser correctly
Some more details of the problem are as-
In the application i m passing some parameters along with the url and depending on that parameters i m generating one output file
the contents of that file is mailed to user.
The contents of the url along with the parameters were generating correctly in browser but when i m trying to get that output in one file to mail the user then the output file is showing 0 k ie no content.
abhijeetgk said that "for normal wget command on unix prompt it is working properly", so it could not be this.feyd wrote:I suspect the site serves different content to different browsers based on their user-agent string. It probably doesn't recognize the one PHP or wget is giving it.
@abhijeetgk - have you tried to execute wget with your Apache user? And post your shell exec script, please.
There are 10 types of people in this world, those who understand binary and those who don't
-
abhijeetgk
- Forum Newbie
- Posts: 9
- Joined: Thu Oct 18, 2007 11:33 pm
- Location: Mumbai
- Contact:
Problem in wget
feyd | Please use
while executing this i m gettin the error as the filesize is 0k
please suggest me solution
thanks
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi
the command i m using is as follows in the script
with this all the paramenters substituted i m getting the proper output in the browser
but with this i m gettin the output "$tmpfname" as blank ie "0k"Code: Select all
system("wget -c 'http://$HTTP_HOST/chiefSecretary/meetingNoticeSubmit.php?". "meetingId=$meeting_inst_Id&meetDay=.$meetDay&meetMonth=". "$meetMonth&meetYear=$meetYear&lang=$lang&langUCase=$langUCase&dept=$dept' -O $tmpfname");
.
.
.
.
$fd = fopen($tmpfname, "r");
$data = fread($fd, filesize($tmpfname));while executing this i m gettin the error as the filesize is 0k
please suggest me solution
thanks
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Have you tried any simple downloads. I.e.:
Does it work?
Also add "-o logfile.log" option to the command line to see what happens.
Code: Select all
system("wget 'http://forums.devnetwork.net' -O $tmpfname");Also add "-o logfile.log" option to the command line to see what happens.
There are 10 types of people in this world, those who understand binary and those who don't
-
abhijeetgk
- Forum Newbie
- Posts: 9
- Joined: Thu Oct 18, 2007 11:33 pm
- Location: Mumbai
- Contact:
problem in host resolving
hi
In the log file as suggested i added the output file, but in that following error occured
Resolving ................failed host not found
but i would like to mention here once again that the same url worked properly in the browser
is this some unix related issue or php related issue ?
thanks
In the log file as suggested i added the output file, but in that following error occured
Resolving ................failed host not found
but i would like to mention here once again that the same url worked properly in the browser
is this some unix related issue or php related issue ?
thanks
VladSun wrote:@abhijeetgk - have you tried to execute wget with your Apache user?
Help me - help youVladSun wrote:Have you tried any simple downloads. I.e.:Does it work?Code: Select all
system("wget 'http://forums.devnetwork.net' -O $tmpfname");
There are 10 types of people in this world, those who understand binary and those who don't
-
abhijeetgk
- Forum Newbie
- Posts: 9
- Joined: Thu Oct 18, 2007 11:33 pm
- Location: Mumbai
- Contact:
it is working
it is working properly
but how can i execute it with apache user in the script ?
but how can i execute it with apache user in the script ?
Code: Select all
sudo -u apache_user_here wget 'http...There are 10 types of people in this world, those who understand binary and those who don't
-
abhijeetgk
- Forum Newbie
- Posts: 9
- Joined: Thu Oct 18, 2007 11:33 pm
- Location: Mumbai
- Contact:
same again
hi
thanks for the help but the problem still persists
what to do now................
thanks for the help but the problem still persists
what to do now................
I meant to run this:
in bash shell, not from PHP script. Does it raise any errors?
Code: Select all
sudo -u apache_user_here wget 'http://forums.devnetwork.net' -O temp.htmlThere are 10 types of people in this world, those who understand binary and those who don't