LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 03-20-2006, 09:21 AM   #1
rajnair0278
Member
 
Registered: Mar 2006
Posts: 62

Rep: Reputation: 15
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!!
 
Old 03-20-2006, 09:49 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
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.
 
Old 03-20-2006, 10:03 AM   #3
rajnair0278
Member
 
Registered: Mar 2006
Posts: 62

Original Poster
Rep: Reputation: 15
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.
 
Old 03-20-2006, 10:53 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
If errors are disabled, it is possible that exec is not permitted on your PHP installation. Also, if you just want to display that file, why not use:
Code:
<?PHP
include("wget http://xxx.xxx.xxx.xxx/filename.csv");
?>
 
Old 03-20-2006, 10:59 AM   #5
rajnair0278
Member
 
Registered: Mar 2006
Posts: 62

Original Poster
Rep: Reputation: 15
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??
 
Old 03-21-2006, 02:13 AM   #6
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
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?
 
Old 03-21-2006, 03:19 AM   #7
rajnair0278
Member
 
Registered: Mar 2006
Posts: 62

Original Poster
Rep: Reputation: 15
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!!!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP / VideoLAN / Fedora Core Question - how can I get the PHP "exec" function to work gtrawoger Linux - Software 3 12-21-2005 06:51 AM
php: output the result of exec( $command ) zovres Programming 6 08-27-2004 06:41 PM
php exec devit Programming 4 04-08-2004 03:26 AM
PHP exec Spooky Programming 1 01-19-2004 08:34 AM
exec cgi from php? barazor Programming 5 01-23-2002 09:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration