Execute an external program

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpfreak
Forum Commoner
Posts: 30
Joined: Fri Mar 21, 2003 10:28 am
Location: New Jersey,USA
Contact:

Execute an external program

Post by phpfreak »

i am trying to execute a .php file after a certain form is submitted. i tried to use exec and others but couldnt succeed; can anybody help me out.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

to execute a .php file directly, you need a shebang (#!/usr/bin/php) as the first line.

what are you processing this form in? If php, why execute the script? Why not include it or redirect to it?
phpfreak
Forum Commoner
Posts: 30
Joined: Fri Mar 21, 2003 10:28 am
Location: New Jersey,USA
Contact:

Post by phpfreak »

what are you processing this form in? If php, why execute the script? Why not include it or redirect to it?
I am processing the form in php but i dont want to use include because
I want to keep it as a separate entity and also, it allows for setting permissions on that particular file.

I tried using "#!/usr/bin/php" but couldnt succeed. can you please help me in here
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

did you remember to set execution permission on "others" ? or whatever php is being executed under..
phpfreak
Forum Commoner
Posts: 30
Joined: Fri Mar 21, 2003 10:28 am
Location: New Jersey,USA
Contact:

Post by phpfreak »

can you please give me an example as to how to write the code for it. It would be of great help
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there's no code you need for it, it's done once. Use your FTP client, if allowed, or your website control panel to set the permissions on the file to execution by the apache/php user (most likely 'nobody', so 'other' needs to be set)
Post Reply