473,503 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exec and Redirecting Output

Hi all,

I've searched high and low on this group and elsewhere and can't
really seem to find an answer to this question. I'm running PHP4 on a
Debian box with Apache. I'm trying to run the "exec" command
withsomething fairly simple like "cat", e.g. exec("cat < a.txt >
b.txt");. I'm noticing that no matter what kind of
redirecting/piping/whatever you want to call it I do, the redirections
don't work (at least the redirecting of the output). I can run the
same command from the command line and it works (of course).

Is this some kind of permissions deal? I've tried making the call to
be in places where a.txt and b.txt are in a directory that have R/W/X
permissions for PHP (I chose a directory that I actually can
successfully use the fopen et al commands with, including writing).

Does anyone have any ideas?

Thanks in advance!

Sep 13 '06 #1
1 2108
bt*********@gmail.com wrote:
Hi all,

I've searched high and low on this group and elsewhere and can't
really seem to find an answer to this question. I'm running PHP4 on a
Debian box with Apache. I'm trying to run the "exec" command
withsomething fairly simple like "cat", e.g. exec("cat < a.txt >
b.txt");. I'm noticing that no matter what kind of
redirecting/piping/whatever you want to call it I do, the redirections
don't work (at least the redirecting of the output). I can run the
same command from the command line and it works (of course).

Is this some kind of permissions deal? I've tried making the call to
be in places where a.txt and b.txt are in a directory that have R/W/X
permissions for PHP (I chose a directory that I actually can
successfully use the fopen et al commands with, including writing).

Does anyone have any ideas?

Thanks in advance!
Redirection is done by the shell, not the OS. If you want to use
redirection you either need to invoke your program through the shell or
handle the redirection yourself (much easier in C/C++ than PHP, although
still not easy).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 14 '06 #2

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

Similar topics

6
2021
by: Thomas Mlynarczyk | last post by:
Hello! I run PHP 4.3 as an Apache module. I use Apache 1.3 as a service under WinXP. And I've got a strange problem with exec(): The following commands are executed correctly:...
14
11649
by: Hemanth | last post by:
Hello there, I'm new to PHP. I'm trying to run a simple php script (on a Red hat linux machine with apache web server ) through a windows web browser (IE). I'm using an exec() function in my...
1
5058
by: Hal Vaughan | last post by:
I've been using Runtime.exec() like this: Runtime rt = Runtime.getRuntime(); try {Process p = rt.exec("MyCommand.bat");} catch (Exception e) {do stuff} When I start my Java classes, I start...
5
5766
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...
5
1855
by: Nick Jacobson | last post by:
This works fine: x = 1 def execfunc(): print x execfunc() So why doesn't this? s = \
1
2216
by: Andr? Roberge | last post by:
I have the following two files: #--testexec.py-- def exec_code(co): try: exec co except: print "error" #-- test.py--
7
2188
by: JahMic | last post by:
I'm having a problem with exec on my hosting server. Unfortunately, the hosting support seems to be anything but helpful. The following works fine on my localhost: <?php $MaskData =...
23
9337
by: Maarten | last post by:
Howdy, Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and I have a little problem with one function within my cd-management script. For extracting a bit of info from my...
2
2977
by: Chuckk Hubbard | last post by:
If I run 'python -i subprocessclient.py' I expect to see the nice level of it go up 2, and the nice level of the subprocess go up 1. But all I see is the nice level of the client change. What am I...
0
7205
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
7093
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
7287
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
7467
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...
1
5022
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...
0
3177
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...
0
1521
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 ...
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
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...

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.