Executing linux commands in a different directory

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
indika
Forum Newbie
Posts: 1
Joined: Thu Feb 01, 2007 11:47 pm

Executing linux commands in a different directory

Post by indika »

:roll: Ok I'll give you the problem straight. I want to move to seperat directory from which I'm working and then issue commands.

Assume I need to move to root and then issue the command 'pwd'.

I tried

system("cd /");
system("pwd");

this gives me only the path which I work. Not the root.

Please help 8O , I'm new to PHP but not to programming. I'd appreciate if anybody can give me example codes

Thanks
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

Try:

Code: Select all

system("cd /; pwd");
Post Reply