system(), exec(), etc.

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
joshw99
Forum Newbie
Posts: 3
Joined: Wed Jul 16, 2003 2:39 pm

system(), exec(), etc.

Post by joshw99 »

I am having trouble getting any of the system commands working (including the backticks even when I do just a simple 'ls' command). I have checked the safe_mode settings and they are off. The only thing I can think of, is that these commands only work if the creater of the script is root (although I doubt this is the case). Any help would be greatly appreciated!
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

What os?
any errors/warnings?
if linux or unix try echo `env 2&>1`;
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

btw, also try with full path, ENV may be cleared.... exec('/bin/ls');
joshw99
Forum Newbie
Posts: 3
Joined: Wed Jul 16, 2003 2:39 pm

Post by joshw99 »

I am using redhat 7.3

Thanks for the help (and quick response!). it seems that the ENV variables have been cleared, as /bin/ls did work. I am going to retry what I was trying to do with a full path! Thanks again
joshw99
Forum Newbie
Posts: 3
Joined: Wed Jul 16, 2003 2:39 pm

Post by joshw99 »

I tried a few things (some things worked some didn't). Ultimately I want a couple things to work:

1) I want to be able to create and delete directories (both of which don't work right now). However, this can be done using the mkdir() and rmdir() functions within php, so this isn't such a big problem.

2) I want to run a script that has execute permissions for all. I tried running it and it won't work, and I am not sure why (I did and 'or die()' statement on the system command and it did in fact die so I know it isn't running)
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

or die is based on the return of the statement ahead, if that one retruns nothing, as many unix/gnu tools do, it will die.. if you include the 2&>1 after the command it will capture STDERR and include that in the output..
Post Reply