Unable to create file using exec()

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
catchkasi
Forum Newbie
Posts: 3
Joined: Thu Oct 16, 2003 4:43 pm

Unable to create file using exec()

Post by catchkasi »

Hi all,
I tried to run an executable file (which creates few files) from php using exec() function of php. But it does not create the files. What could be the problem?

Thanks,
Kasi
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

I take it the .exe file is on the server?
catchkasi
Forum Newbie
Posts: 3
Joined: Thu Oct 16, 2003 4:43 pm

Post by catchkasi »

Yes its in the server. I would like to add that I am able to create files from php directly.

Thanks,
Kasi
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Problems with using system functions such as exec() usually comes down to either paths or permissions.

So try using the full path to the executable and also check it has sufficient permissions.

Also, if you're using *nix then you can easily find out what's wrong by doing 'su - apache' (or whoever the web server is running as) and run the exact same command you use in the exec(). .. this requires root access too though.
catchkasi
Forum Newbie
Posts: 3
Joined: Thu Oct 16, 2003 4:43 pm

Post by catchkasi »

The path is not the problem as I can run other executable that dont open or create files. Also I am working in Linux, so could you explain how I could check whatz happening when I run exec() function.

Thanks,
Kasi
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

You could 'su - apache' (or whoever the webserver runs as) and run the script that creates the files as that user.
Post Reply