I'm trying to run a command with wine via php:
Code: Select all
<?php
$test = shell_exec('wine c:\\\\.exe');
echo $test;
?>
Code: Select all
<?php
$test = shell_exec('wine c:\\\\.exe');
echo $test;
?>
Code: Select all
<?php
$test = shell_exec('wine c:\\\\program.exe');
echo $test;
?>
The set of environmental variables available in a webserver environmentI'm trying to run a command with wine via php:
Code:
<?php
$test = shell_exec('wine c:\\\\program.exe');
echo $test;
?>
It doesn't work. but the same command : wine c:\\program.exe
Works fine in the SSH directly.
I tried with php shell_exec('wine --version') and I received my wine
version but can't run the program through my browser (php).
Do you see any error messages?Thanks for the replay.
I compared them:
PWD in shell is /root, with php is the document root of my site.
HOME in shell is /root, with php is /var/www
PATH in shell is /usr/lib/kde4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin but in php it is /sbin:/usr/sbin:/bin:/usr/bin
Another vairable in shell is:
_=/usr/bin/env
in php:
_=/etc/init.d/php-fastcgi
Should I change these for php and how? and how to set them b ack after
I ran the program?
So, exactly what did you do and what error messages did you see? UnlessI changed all the env variables and test them, they were all changed.
but still no success.
Are you using any secure Linux features (AppArmour, SELinux, etc)?
To run most (all) programs Wine needs X display. If you running this on the server you'll need to setup a virtual X server and point Wine to it (DISPLAY env var).asmith wrote:I'm trying to run a command with wine via php: It doesn't work. but the same command : wine c:\\program.exe Works fine in the SSH directly.
Its unlikely that there aren't traces in some log file: one of theActually I have done that.
I have setup xvfb and I've run 'Xvfb :1 &'
and I run the command I need with:
DISPLAY=:1 wine program.exe
All works perfectly fine directly in shell. I have no idea why in php
NOTHING happens. I get a blank screen. no output. no error.
Is that program writing to stdout or stderr?I tested with another exe file, which I created using C++ in windows.
the program only print out a test line like 'hello!', when running.
You ran that as what user?asmith wrote:I ran that program in shell: wine program2.exe, and I received the text.
In most systems apache and php running under highly restricted user with big memory restrictions. Also Wine needs to setup it's prefix on first run.asmith wrote:Again I tested the same line in php, a blank screen. no output, no error.
Well yeah, wine --version doesn't get any further then wine launcher itself which has version hardcoded during compile time.asmith wrote:in mean time I DO get output for: 'wine --version', or 'ls -al'
You shouldn't run Wine as root...I enabled error logging and no error was there.
But funny thing, I changed
'wine c:\\\\program.exe'
to
'wine /root/.wine/drive_c/program.exe'
and it worked. I tried c:\\program.exe, but nothing.
However I have another problem. the original line was like this: (sending a file to the program)
wine program.exe -file test.ext
now this in shell:
wine /root/.wine/drive_c/program.exe -file test.ext
works fine as it should.
but same line in php, tells that the program can't find the file.
test.ext is in .../drive_c/temp and the program always look for files in the temp folder. so it finds the file in temp folder if it is in shell, but it can't infd the file if it is in php.
Any idea?
Create another user and log in as that user. How exactly are you running it from php?asmith wrote:wine again created .wine in root. (I am logged as root for now) How do I change it?
You have to specify full path to both executable and your input file. Both have to be Windows paths not UNIX. To convert paths use program 'winepath'.asmith wrote:wine /root/.wine/drive_c/program.exe -file test.ext
Assuming you're again logged in as root:I'm sorry I'm newbie on linux and wine, but I'm trying my best.
I did:
mv /root/.wine /home/username/.wine
and
env WINEPREFIX=/home/username/.wine
But wine didn't changed its prefix.
by
wine program.exe
wine again created .wine in root. (I am logged as root for now)
How do I change it?
PHP should also not be running as root...I created another profile for wine in /home/username/.wine/
But my php still uses the root username to access, so it uses wine profile for root.
Get the logs!I think I narrowed down the problem. I have permission issues.
Wine can run the program itself. but when program.exe wants to start its processing, it fails creating its own temp files or accessing some files it needs on the system.
When running it directly in shell, it has full access to any file, that's why it works fine. But with php it doesn't.
move it, set the WINEPREFIX environment variable to point to it...chowning wine profile doesn't seem to work.
How can I move my .wine to another folder? I dont' wanna create another one. Just move this working one to my public_html folder, so that maybe it works there? or just find the option in apache (I use nginx) to give permission to this one.
You my friend are a hacker's delight. Hopefully your php is not publicI created another profile for wine in /home/username/.wine/
But my php still uses the root username to access, so it uses wine profile for root.