Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exec on Windows XP apache 2

Status
Not open for further replies.

801119

Programmer
Apr 10, 2000
311
SE
Greetings all,

It is driving me nuts, I cant figure out how to use exec, and it's vital for me that I make it work :( else I can't force ftp to update userlist =(

I'm running Windows XP sp1 and apache 2-somthing =)

$exe = "C:\program files\program\file.exe -reload";
exec($exe);

this does nothing :( what's wrong? I've tried numerious different ways to do it, but it just wont work

thanks

My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
It's the way PHP is interpreting your exec string.

PHP interpolates values inside double-quoted strings, but not values inside single-quoted strings.

Also, the backslash character is used in PHP as an escape character.

So PHP is interpreting the string:

"C:\program files\program\file.exe -reload"

as

&quot;C:<escape-p>program files<escape-p>rogram<escape-f>ile.exe -reload&quot;

Here's a few workarounds:

Put the string inside singe-quotes instead of double-quotes:
'C:\program files\program\file.exe -reload'

PHP interprets two backslashes together as the backslash character. Rewrite your string as:
&quot;C:\\program files\\program\\file.exe -reload&quot;

Use forward-slashes instead of backslashes. PHP will probably be able to use them as the directory delimit character, even on Win32:
&quot;C:/program files/program/file.exe -reload&quot;;


I'd recommend using single-quotes or forward-slashes. Double-backslashes aren't pretty.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
when i use exec(&quot;\&quot;D:\\wwwserver\\NOTEPAD.EXE\&quot;&quot;);(copied notpad there :p) it just tries to load the program and waits for it to end.. and it never does what it's suposed to do =/

My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
oh? That's too bad, then I need to write my own crapy command-prompt program that will execute another program, than quit... lol

but, all I need to do is refresh my &quot;BPFTP Server&quot;, and it's already running.

Whenever I run that way,

exec(&quot;\&quot;C:\\programs\\G6FTPSrv.exe -reload\&quot;&quot;); it works fine, but never reloads my user.ini files.. perhaps it's something wrong my the command line, though the readme files states that -reload is the way to do it :/

My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Similar problem, Im running the line below, however its creating the file, but at 0 bytes??? The command is correct cause you can execute the command at the command line and it creates the file correctly.

<?php
exec('C:\Progra~1\Apache~1\Apache2\bin\htpasswd.exe -c -b C:\password.pwd usrME pwdME');
?>

Anyone any ideas???

Tony
 
Keep in mind that when you run the command, you use your login user's permissions. When Apache runs the command, you're using the permissions of the user as which Apache runs on the system.

Check the permissions of the directory where the file is to be written. Better still, don't write to the root of C: -- create a directory where you can set write permissions for Apache's user and tell htpasswd.exe to write the file there.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top