Problems with exec and psexec

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
juantxito
Forum Newbie
Posts: 2
Joined: Wed Jan 19, 2011 11:25 am

Problems with exec and psexec

Post by juantxito »

Hi,

I'm having a big problem using the exec() function. I want to execute a remote cacls to view and parse the returned accesslist. I use PsExec from SysInternals, and it's a Windows environment (and active directory) with apache. The problem is this:

Making some tests, I have checked thar the following line works:

$comando = 'psexec \\\\'.$_CONFIG['equipoRemotoPsExec'].' -u '.$_CONFIG['userPsExec'].' -p '.$_CONFIG['passwdPsExec'].' -accepteula cacls "C:\\Install\\SUPPORT"';

exec ($comando, $arr );

and it returns the accesslist.

(psexec \\remote address -u user -p password -accepteula command)

But the remote folder must be a parameter (variable) and after spending too many hours, I`ve checked that if the destination folder parameter has some spaces, it won't work (and it could happen):

$comando = 'psexec \\\\'.$_CONFIG['equipoRemotoPsExec'].' -u '.$_CONFIG['userPsExec'].' -p '.$_CONFIG['passwdPsExec'].' -accepteula cacls "C:\\Documents and Settings\\All Users\\Desktop"';

exec ($comando, $arr);

Any suggestions or ideas? Has someone have this problem too?

Thak you very much and sorry about my english,

Juan
Peter Kelly
Forum Contributor
Posts: 143
Joined: Fri Jan 14, 2011 5:33 pm
Location: England
Contact:

Re: Problems with exec and psexec

Post by Peter Kelly »

When its a space change it to %20 possibly?
juantxito
Forum Newbie
Posts: 2
Joined: Wed Jan 19, 2011 11:25 am

Re: Problems with exec and psexec

Post by juantxito »

Uhmm... good idea, thank you, but it doesn´t work. I'm afraid I'll must rename all the files and directories in the remote computer that could be searched by removing all the blank spaces in their names...

Thank you very much for the reply !!
Post Reply