473,574 Members | 2,450 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wanna execute a bin proggy and get result

tom
Problem:
In PHP, need to execute a program in (freebsd terms) /usr/local/bin
in meta-terms:
int i;
i = [execute command](arguments);

There seems to be quite a few execution methods in PHP
(sorry in advance for being thick), and, er, I was
wondering if someone could give me a quick pointer
to appropriate ones I should study to:

1. execute a command and wait till it finishes
2. enable a bunch of arguments to be sent to it
3. receive an integer from the completion of that command
{i.e. if the command is in C++,
which it will be, then it returns from and exit(interger) }.
Maybe, as a bonus,
4. timeout if the command does not return

Its a lot to ask, but from what I see so far in PHP
(and I am becoming a fan) then I reckon it can be done.

Many thanks, tom

Jul 17 '05 #1
4 2057
"tom" <te**@nospam.co m> wrote in message
news:bt******** ***********@new s.demon.co.uk.. .
Problem:
In PHP, need to execute a program in (freebsd terms) /usr/local/bin
in meta-terms:
int i;
i = [execute command](arguments);

There seems to be quite a few execution methods in PHP
(sorry in advance for being thick), and, er, I was
wondering if someone could give me a quick pointer
to appropriate ones I should study to:

1. execute a command and wait till it finishes
2. enable a bunch of arguments to be sent to it
3. receive an integer from the completion of that command
{i.e. if the command is in C++,
which it will be, then it returns from and exit(interger) }.
Maybe, as a bonus,
4. timeout if the command does not return

Its a lot to ask, but from what I see so far in PHP
(and I am becoming a fan) then I reckon it can be done.

Many thanks, tom

$res = `/usr/local/bin/cmd_to_execute param1 param2`;

$res will be a string of stdout

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #2
CountScubula wrote:
"tom" <te**@nospam.co m> wrote in message
news:bt******** ***********@new s.demon.co.uk.. .
Problem:
In PHP, need to execute a program in (freebsd terms) /usr/local/bin
in meta-terms:
int i;
i = [execute command](arguments);

There seems to be quite a few execution methods in PHP
(sorry in advance for being thick), and, er, I was
wondering if someone could give me a quick pointer
to appropriate ones I should study to:

1. execute a command and wait till it finishes
2. enable a bunch of arguments to be sent to it
3. receive an integer from the completion of that command
{i.e. if the command is in C++,
which it will be, then it returns from and exit(interger) }.
Maybe, as a bonus,
4. timeout if the command does not return

Its a lot to ask, but from what I see so far in PHP
(and I am becoming a fan) then I reckon it can be done.

Many thanks, tom


$res = `/usr/local/bin/cmd_to_execute param1 param2`;

$res will be a string of stdout
--
Mike Bradley
http://www.gzentools.com -- free online php tools

It's important to note that those are *backticks*. Single quotes would
dump the line as a string into $res. Also, if safe mode is enabled,
then the backtick operator won't work. It'd probably be better to use
exec().

*nix: $res = exec("/usr/local/bin/cmd_to_execute param1");
- or -
Windows: $res = exec("c:\somewh ere_in_the_syst em_path\foo.exe param1");

Good notes 'bout the backtick (and a couple of samples):
http://www.php.net/manual/en/languag....execution.php
exec():
http://www.php.net/manual/en/function.exec.php

The documentation at php.net just rocks... if you have a good idea of
what you're looking for is called. =)

Warm regards,

- Dan

Jul 17 '05 #3
In regards to (4), there's no good way to do it in PHP.

Uzytkownik "tom" <te**@nospam.co m> napisal w wiadomosci
news:bt******** ***********@new s.demon.co.uk.. .
Problem:
In PHP, need to execute a program in (freebsd terms) /usr/local/bin
in meta-terms:
int i;
i = [execute command](arguments);

There seems to be quite a few execution methods in PHP
(sorry in advance for being thick), and, er, I was
wondering if someone could give me a quick pointer
to appropriate ones I should study to:

1. execute a command and wait till it finishes
2. enable a bunch of arguments to be sent to it
3. receive an integer from the completion of that command
{i.e. if the command is in C++,
which it will be, then it returns from and exit(interger) }.
Maybe, as a bonus,
4. timeout if the command does not return

Its a lot to ask, but from what I see so far in PHP
(and I am becoming a fan) then I reckon it can be done.

Many thanks, tom

Jul 17 '05 #4
http://www.gzentools.com -- free online php tools
"Chung Leong" <ch***********@ hotmail.com> wrote in message
news:ct******** ************@co mcast.com...
In regards to (4), there's no good way to do it in PHP.


you could possibly try wrapping the call in another php script that your
main one calls, and do a set time put to that script.

just a thought, not tested, so, it a theory ;)

--
Mike Bradley

Jul 17 '05 #5

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

Similar topics

1
6813
by: Sheila King | last post by:
I have searched for an answer to this question on the comp.lang.python archives at Google Groups, and also looked through the (sparse) MySQLdb documentation, and cannot confirm for a FACT what I think I know. Looking for affirmation before I go "assuming" something and getting myself into trouble somewhere along the line... Here is what I...
2
1886
by: Mats | last post by:
We have a webshop that has frames (content and "menu in two parts") I'm experimenting with the general layout and have changed the location of the link to the cart to be in the (upper) menu frame. The cart is hidden unless you "call" it. When something is added to the cart there is a redirect back to where the customer put something in the...
3
8003
by: Me | last post by:
hi, I have this file I need to execute from an ASP client. since we have installed it on the SQL Database server machine, I thought I could run it like this: Set Cn = CreateObject("ADODB.Connection") Cn.CursorLocation = adUseClient Cn.ConnectionTimeout = 0
6
5284
by: PiGei | last post by:
hi all, I'm trying to use server.execute statement to include in an asp page another asp page with a parameter. That's because I've a parametric query in the second asp page and I have to pass the value <% Server.Execute("result.asp?key=2") %> I can't do it. That's the error message I get:
9
9373
by: PyPK | last post by:
Hi if I have a function called tmp=0 def execute(): tmp = tmp+1 return tmp also I have def func1(): execute() ....
5
12402
by: Gustavo Randich | last post by:
Hello, I'm writing an automatic SQL parser and translator from Informix to DB2. Now I'm faced with one of the most difficult things to translate, the "foreach execute procedure" functionality provided by Informix. This is the problem: the execution of the translated SQL leaves the rows in the temp table correctly but raises error SQL0480N....
5
18694
by: John Grandy | last post by:
Is there any way in C# to mimic the T-SQL EXEC() command (which runs a string as if it was in-line T-SQL code) ?
2
4481
by: Wei Wang | last post by:
Hi, I want to do a select in dynamic command, something like: TRIGGER FUNCTION DECLARE table_name_suffix text; temp_result RECORD; temp_result2 RECORD;
3
6951
by: Rahul Babbar | last post by:
Hi, I have the following doubt. Suppose I use the execute immediate statement and the statement to be executed is a Select statement from the sysibm.sysdummy1 table which will always return me one row. Further, i need to capture the result of the execute Immediate into a
0
7794
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8040
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8225
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7800
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8092
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5296
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3745
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1051
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.