473,411 Members | 2,210 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,411 software developers and data experts.

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 3559
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*******@attglobal.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.*********@gmail.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*******@attglobal.net
==================
Sep 12 '07 #4
On Sep 12, 1:19 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
c.g.dang...@gmail.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...@attglobal.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
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...
2
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...
5
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...
1
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...
9
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...
4
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...
5
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 "{}"...
13
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...
26
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....
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.