Urgent!!!!! Help with wget and php exec command ??
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Urgent!!!!! Help with wget and php exec command ??
I execute wget http://<path>/file.txt at the linux prompt and it downloads the file smoothly. However when I enter exec("wget http://<path>/file.txt") in a download.php and execute it in a browser it doesnot download?? Any suggestions and help ?? Pls Urgent!!
First question, can you confirm that any PhP code get's executed via the browser? Is it just one command that fails, or the entire program? Do the PhP logs tell you anything?
If I'm not mistaken, you can also try executing the PhP code from the command line. Does that work?
Also, doesn't the exec command tell you the return code of the command executed?
My last guess would be that PhP may interprete the path if it contains certain special characters. You
should check if for anything abnormal.
Yeah am sure the php code is getting executed in the browser. I tried phpinfo(); in index.php and its fine. Also some other small cookie programs and that too is working smoothly. Where can I check the log file?? No, its not getting executed from the command line. I dont have anything else in my download.php except this one line.
<?php
exec("wget http://xxx.xxx.xxx.xxx/filname.csv");
?>
..thats it. What could possibly be wrong in this path?? Is there any other way I can write this to overcome the slashes errors if any. Am relatively new to this language?? Any help will be appreciated.
I dont want to just include that file I want to download it. After downloading I want to import the csv separated columns into a database. The reading of this csv file is done through a .php file. And all this will be included in a cron file but that comes later. What is so frustrating is the basic thing itself is not working, leave alone the rest?? Thanks for the reply. Will chk php.ini for some clues. In the meantime help from anyone will be appreciated??
What kind of database are you talking about? MySql? If so, then I recommend trying to forget about the web interface and using a simple shell/PhP/Perl script (executed from the shell by cron) instead. That avoids having to load the browser.
Browsing is for users to look at web pages, download stuff, etc. It's not intended nor efficient for automatic downloads.
Edit: what kind of alterations need to be done on the text/csv files in order to insert them into the database?
No timmeke, the web interface was just to check the exec and wget function. Anyways, to cut it short: i checked the error_log and it said permission denied whenever I was downloading the php file. So I changed the permission of my download file and its fine now. It was a very small issue now that its done ;-) :-). Thanks everybody for everything. It was a nice learning experience. With you guys out there am sure working on linux should not be a big issue very soon. Right folks?? Cheers!!!!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.