C
Csaba
Hi, I'm at a bit of a loss here - I'd like to activate a program which
demands keyboard input and then provide a single line of input, which
will terminate the program. I'll provide the specifics in the next
paragraphs, and then the motivation.
I'm running a VBScript program (this is actually via an
MSScriptControl.ScriptControl COM object) and I want to execute a Run
command:
Dim oWSH
Set oWSH = CreateObject("WScript.Shell")
oWSH.Run "cmd /C php-cgi -a ...", 0, true
Now, this Run command wants to invoke php-cgi.exe to run a short
script. However, the only way that php-cgi.exe accepts a non file
script is by going into interactive mode. So, ... from the keyboard, I
would do:
php-cgi -a
<?php $o=new COM('WScript.Shell');$o->popup('Working');exit(); ?>
Of course, that second line is typed interactively and received by
php-cgi.exe, not the command interpreter. And the final exit causes
php-cgi to terminate. My question is:
Is there a way that I can specify to CMD (within the oWSH.Run command)
that it should send that second line to STDIN?
Thanks,
Csaba Gabor from Vienna
For the curious, the real problem I'm trying to solve is that I want to
be able to display (upon an instance of IE invoked with $ie=new
COM("InternetExplorer.Application")) the phpinfo() that the CLI
(command line interpreter) versions of PHP return. These CLI versions
are php.exe and php-win.exe. What happens, however, is that the CLI
versions only return a text version of phpinfo() and not an HTML
version, so I should have to format it myself. However, there's a lot
of style sheet information within this HTML formatting and I would
rather get this in an automated way.
My idea for how to do this is to invoke php-cgi.exe (which DOES provide
the type of formatting I want) and strip the <style>...</style> portion
of the output. And I can do this via the process described at
http://php.net/proc_open . Unfortunately, invoking proc_open results
in a nasty command prompt flash. Now, this ugly flash is avoided if I
take a similar approach using a ScriptControl COM object, which is how
I got to the question above. Of course I will have slightly longer
code to supply top php-cgi, but the code above illustrates the idea.
demands keyboard input and then provide a single line of input, which
will terminate the program. I'll provide the specifics in the next
paragraphs, and then the motivation.
I'm running a VBScript program (this is actually via an
MSScriptControl.ScriptControl COM object) and I want to execute a Run
command:
Dim oWSH
Set oWSH = CreateObject("WScript.Shell")
oWSH.Run "cmd /C php-cgi -a ...", 0, true
Now, this Run command wants to invoke php-cgi.exe to run a short
script. However, the only way that php-cgi.exe accepts a non file
script is by going into interactive mode. So, ... from the keyboard, I
would do:
php-cgi -a
<?php $o=new COM('WScript.Shell');$o->popup('Working');exit(); ?>
Of course, that second line is typed interactively and received by
php-cgi.exe, not the command interpreter. And the final exit causes
php-cgi to terminate. My question is:
Is there a way that I can specify to CMD (within the oWSH.Run command)
that it should send that second line to STDIN?
Thanks,
Csaba Gabor from Vienna
For the curious, the real problem I'm trying to solve is that I want to
be able to display (upon an instance of IE invoked with $ie=new
COM("InternetExplorer.Application")) the phpinfo() that the CLI
(command line interpreter) versions of PHP return. These CLI versions
are php.exe and php-win.exe. What happens, however, is that the CLI
versions only return a text version of phpinfo() and not an HTML
version, so I should have to format it myself. However, there's a lot
of style sheet information within this HTML formatting and I would
rather get this in an automated way.
My idea for how to do this is to invoke php-cgi.exe (which DOES provide
the type of formatting I want) and strip the <style>...</style> portion
of the output. And I can do this via the process described at
http://php.net/proc_open . Unfortunately, invoking proc_open results
in a nasty command prompt flash. Now, this ugly flash is avoided if I
take a similar approach using a ScriptControl COM object, which is how
I got to the question above. Of course I will have slightly longer
code to supply top php-cgi, but the code above illustrates the idea.