473,770 Members | 2,144 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Single cmd/bash session for all exec() calls - is this possible?

Hello

My PHP script executes many bash/cmd commands.
Functions like "exec()" or "system()" cause that new bash/cmd session
is started,
the command is executed and the session is closed. Unfortunately
it is very slow process so I would like to increase performance and
open one bash/cmd session on the begin of my script and execute
the commands such as in normal system opened bash/cmd window and close
it
at the end of my PHP script.
Does anybody know whether and (if yes) how can I do that?

PS. I need the retrieve informations from previous command before
executing next command because next command is strongly dependent on
the
results from previous command.

Best regards
Melmack

Sep 12 '07 #1
4 3579
me******@gmail. com wrote:
Hello

My PHP script executes many bash/cmd commands.
Functions like "exec()" or "system()" cause that new bash/cmd session
is started,
the command is executed and the session is closed. Unfortunately
it is very slow process so I would like to increase performance and
open one bash/cmd session on the begin of my script and execute
the commands such as in normal system opened bash/cmd window and close
it
at the end of my PHP script.
Does anybody know whether and (if yes) how can I do that?

PS. I need the retrieve informations from previous command before
executing next command because next command is strongly dependent on
the
results from previous command.

Best regards
Melmack
Melmack,

You might be able to open the command shell with proc_open() and
communicate through the pipes.

I've never tried it in PHP, but done similar in C before.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Sep 12 '07 #2
On Sep 12, 6:50 am, melma...@gmail. com wrote:
Hello

My PHP script executes many bash/cmd commands.
Functions like "exec()" or "system()" cause that new bash/cmd session
is started,
the command is executed and the session is closed. Unfortunately
it is very slow process so I would like to increase performance and
open one bash/cmd session on the begin of my script and execute
the commands such as in normal system opened bash/cmd window and close
it
at the end of my PHP script.
Does anybody know whether and (if yes) how can I do that?

PS. I need the retrieve informations from previous command before
executing next command because next command is strongly dependent on
the
results from previous command.

Best regards
Melmack
I would write a bash script and just execute that from within PHP. If
you're using so many commands that performance is becoming an issue,
I'd recommend that you try that. Bash scripting is terribly easy to
learn if you don't already know how. Even if you did find an
alternative in PHP, I don't think it would be as efficient as
executing a single script.
-c

Sep 12 '07 #3
c.*********@gma il.com wrote:
On Sep 12, 6:50 am, melma...@gmail. com wrote:
>Hello

My PHP script executes many bash/cmd commands.
Functions like "exec()" or "system()" cause that new bash/cmd session
is started,
the command is executed and the session is closed. Unfortunately
it is very slow process so I would like to increase performance and
open one bash/cmd session on the begin of my script and execute
the commands such as in normal system opened bash/cmd window and close
it
at the end of my PHP script.
Does anybody know whether and (if yes) how can I do that?

PS. I need the retrieve informations from previous command before
executing next command because next command is strongly dependent on
the
results from previous command.

Best regards
Melmack

I would write a bash script and just execute that from within PHP. If
you're using so many commands that performance is becoming an issue,
I'd recommend that you try that. Bash scripting is terribly easy to
learn if you don't already know how. Even if you did find an
alternative in PHP, I don't think it would be as efficient as
executing a single script.
-c
You missed one salient point in his post:

"PS. I need the retrieve informations from previous command before
executing next command because next command is strongly dependent on the
results from previous command."

Can't do it with a bash script unless you're willing to do all the work
in the script.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Sep 12 '07 #4
On Sep 12, 1:19 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
c.g.dang...@gma il.com wrote:
On Sep 12, 6:50 am, melma...@gmail. com wrote:
Hello
My PHP script executes many bash/cmd commands.
Functions like "exec()" or "system()" cause that new bash/cmd session
is started,
the command is executed and the session is closed. Unfortunately
it is very slow process so I would like to increase performance and
open one bash/cmd session on the begin of my script and execute
the commands such as in normal system opened bash/cmd window and close
it
at the end of my PHP script.
Does anybody know whether and (if yes) how can I do that?
PS. I need the retrieve informations from previous command before
executing next command because next command is strongly dependent on
the
results from previous command.
Best regards
Melmack
I would write a bash script and just execute that from within PHP. If
you're using so many commands that performance is becoming an issue,
I'd recommend that you try that. Bash scripting is terribly easy to
learn if you don't already know how. Even if you did find an
alternative in PHP, I don't think it would be as efficient as
executing a single script.
-c

You missed one salient point in his post:

"PS. I need the retrieve informations from previous command before
executing next command because next command is strongly dependent on the
results from previous command."

Can't do it with a bash script unless you're willing to do all the work
in the script.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
Perhaps you've misunderstood me: doing all the work in the bash script
was what I had suggested, in fact.

Sep 12 '07 #5

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

Similar topics

3
8258
by: John Bowling | last post by:
I have a java (2.0) program with the following lines: String cmdArray1 = {"lp", "-d", "hp4m", "MyFile"}; System.out.println(Runtime.getRuntime().exec(cmdArray1)); It compliles properly, but does not print the file to the printer. It displays the following as the return from Runtime...: java.lang.UNIXProcess@1034bb5
2
17398
by: Jonathan | last post by:
I'm puzzled by Python's behavior when binding local variables which are introduced within exec() or execfile() statements. First, consider this simple Python program: # main.py def f() : x = 1 print "x:", x f()
5
5782
by: Toby Donaldson | last post by:
Hi all, I'm designing an educational application that will run Python code and check the output against a pre-define answer. I want to use the "exec" statement to run the code, but I don't know how to get output from it. For instance, exec works like this: >>> code = """ for i in xrange(1, 5):
1
1249
by: giatorta | last post by:
Hi all, I have a scenario where the client calls Web Service WS1 and WS1 calls Web Service WS2 I have methods M1 on WS1 and M2 on WS2 both with EnabledSession=True assume M1 on WS1 does the following (in VB-like pseudocode): If (new session) Then Session("foo1") = "OLD1"
9
2297
by: a | last post by:
I already posted on this subject, but I have some more information that should make the issue clearer. Config: Apache 2.x, PHP 5.1.x, Windows XP Pro A php script processes a form. Inside this script I call exec to run a Windows process. If I press the submit button on the form repeatedly, exec starts and exit the process several times, but after 2-3 cycles, it starts the process, the process exits, but exec doesn't return, and it hangs...
4
2372
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of which I mean here. Just for a moment, let's just take one definition for one of the
5
4442
by: BartlebyScrivener | last post by:
I recently moved from XP to Linux, but would like to use Python whenever possible. line from bash script: find ~/Mail -xdev -type f \( -mtime 0 -or -mtime 1 \) -exec cp -aPvu "{}" /backup-dest \; What modules would I use to accomplish this in Python? Or any other Python tricks to copy or backup all files modified today?
13
8674
by: Samir Chouaieb | last post by:
Hello, I am trying to find a solution to a login mechanism for different domains on different servers with PHP5. I have one main domain with the user data and several other domains that need a login to show data. I want the user to login only once when he visits any of my domains.
26
3663
by: warth33 | last post by:
Hello I have a php site. Some page needs to call an external program. The programs are home made c# applications. It uses to work without problem. For a while. Maybe it work for some hour. Or for a day. Or even for a week. At a certain point, when a php script calls the exe file, the application freezes. The following happens:
0
9618
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.