Can't exec() a program that uses mem alloc?

From: Iain Staffell (staffell_at_blueyonder.co.uk)
Date: 12/05/03


To: php-general@lists.php.net
Date: Fri, 5 Dec 2003 18:08:11 -0000

I am trying tooth and nail to create a method of copying a string of text to
the server's clipboard via php.

I have found a couple of short pieces of code to do exactly that in C, so
compiled the program and in a command prompt it works like a charm - in my
case it reads the contents of a text file and copies that to the clipboard.

I then try using a php script to execute that file using shell_exec(),
exec() and system() to no luck, every time the command:

$outpt = shell_exec("clipboard.exe") or die ("failed to execute");Would just
print out the die message.

I set about writing my own C program to copy the contents of the text file
first to the screen, and then to a char array which could then be passed to
the clipboard.

All of these self made programs could be executed by shell_exec() - so I
thought I was finally onto a winner. However it seems that I can't just pass
a char array to SetClipboardData - it has to be a block of Globally Movable
memory, which sadly I don't understand.

Is there any reason why PHP shell_exec() or other execution commands are
unable to run a program that tampers with memory? I can't say I understand..
The other question would be - how could I modify either of the exe files to
work with PHP?

Thankyou for your time and knowledge :)

clipper.php <-- php code for shell_exec commands. change which line is
commented to test the second method
clipboard.cpp <-- clipboard executable found from google, works in command
prompt but 'fails to execute' with PHP
clipper.cpp <-- clipboard executable I wrote, which doesn't actually work,
but can be executed with PHP



Relevant Pages

  • Re: IIS 6.0 on Windows Server 2003
    ... If PHP insists on using CMD.EXE to execute the shellcommand on the ... server, then no, you have no choice -- you must give read permissions to the ... this would be a security vulnerability caused by PHP. ...
    (microsoft.public.inetserver.misc)
  • Re: IIS 6.0 on Windows Server 2003
    ... >If PHP insists on using CMD.EXE to execute the shell ... command on the ... caused by PHP. ... >since IIS directly executes the web page, ...
    (microsoft.public.inetserver.misc)
  • Desperate: php exec - works in one case, but not other
    ... I am trying to use the php exec function to execute 2 programs, ... call the exec command twice. ... if the php is run via a webpage. ...
    (php.general)
  • Re: cron jobs in PHP admin to run a PHP file
    ... "command" in cron jobs I don't know what it is looking for? ... All I want to do is run the php script. ... have permission to execute it. ...
    (comp.lang.php)
  • Re: cron jobs in PHP admin to run a PHP file
    ... "command" in cron jobs I don't know what it is looking for? ... All I want to do is run the php script. ... you have to have permission to execute it. ... That's what cron jobs are - command line jobs, ...
    (comp.lang.php)