473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Execute extneral programs with interactivity?

I'm using PHP in command-line mode. I would like to run an external
command, and have it interact with the user just as if he had ran it
from a shell. (I don't need my script to send input to the command).
Ideally I would also like to capture the STDOUT into a variable,
although this is not a requirement.

None of the PHP program-execution commands seem to work for me. The
closest I've come is:
system("ftp")
which takes user input, but it seems to buffer the output until you
type something other than a carriage return. I want it to behave
exactly as it does from a shell. Is this possible?

Thanks,
Jacob

Oct 19 '05 #1
3 1104
we********@gmail.com wrote:
I'm using PHP in command-line mode. I would like to run an external
command, and have it interact with the user just as if he had ran it
from a shell. (I don't need my script to send input to the command).
Ideally I would also like to capture the STDOUT into a variable,
although this is not a requirement.

None of the PHP program-execution commands seem to work for me. The
closest I've come is:
system("ftp")
which takes user input, but it seems to buffer the output until you
type something other than a carriage return. I want it to behave
exactly as it does from a shell. Is this possible?

Thanks,
Jacob

Take a look at proc_open.

http://www.php.net/proc_open
--
Mike Willbanks
Zend Certified Engineer
http://www.digitalstruct.com
Oct 20 '05 #2
I looked at that ... after checking out some of the examples, I was
able to make it do basically the same thing that system() or popen()
was doing. It still doesn't seem to handle user input normally.

I guess I need to send the stdin (from the PHP script) to the stdin of
the process that I open. But how do I do that?

Thanks,
Jacob

Oct 20 '05 #3
we********@gmail.com wrote:
I looked at that ... after checking out some of the examples, I was
able to make it do basically the same thing that system() or popen()
was doing. It still doesn't seem to handle user input normally.

I guess I need to send the stdin (from the PHP script) to the stdin of
the process that I open. But how do I do that?

Thanks,
Jacob


On Microsoft/Linux/Unix with a recent PHP:

$inh=fopen("stdin://", 'r');

With Linux/some Unix:
$inh=fopen("/dev/stdin", 'r');

C.
Oct 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: BlackHawke | last post by:
Our program, game program Andromeda Online (www.andromedaonline.net) uses two programs- one to play the game, another to patch the game as updates come out. Players actually launch the updater...
3
by: Krisztian Kepes | last post by:
Hi ! I want to start many py programs - with other parameters. Because the programs have many to-do, I don't want to wait for them. In Delphi it is like this: >>>>>>>>>>>>>>>
0
by: Andy Leszczynski | last post by:
Hi, I need a help with following problem which is blocking me quite seriously. I noted some weird behavior on Windows (Python 2.3, wxPython 2.5). The same code works fine under Linux. When...
0
by: zaemin | last post by:
Hello, I'm designing streamable animation format like flash. I have some questions. My animation format has interactive feature by script. A designer can insert 'gotoFrame' action on the...
2
by: Sam | last post by:
Sorry one of those "C" type transistion questions which I could find no answer for in existing C# text books. In C, I used to use the system function call to execute programs synchronously. ...
2
by: Christine.Misseri | last post by:
Hi all, I'm sure someone knows about this problem. I have an Access database designed in Access 2000, connected to an ORACLE 8i back end. On the ORACLE side I have stored procedures, triggers...
2
by: nareshdacha | last post by:
Is it possible to execute c programs from DOS? If it is possible plz send me details to naresh185@gmail.com
7
by: Brian Erhard | last post by:
I am still fairly new to python and wanted to attempt a home made password protection program. There are files that I carry on a USB flash drive that I would like to password protect. ...
15
by: tmp123 | last post by:
Hello, Thanks for your time. We have very big files with python commands (more or less, 500000 commands each file). It is possible to execute them command by command, like if the commands...
1
by: Kitu | last post by:
Hey!! I just wanna know tht,,,How to compile n execute c/c++ programs in Microsoft Command Prompt......
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.