473,763 Members | 6,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running a shell script in PHP does not create valid output file

43 New Member
I am using Linux Suse10, php 5 .

execute a shell script in a terminal, it works. output is a file with data .

when I use it in php like this (code : php) :
Expand|Select|Wrap|Line Numbers
  1. chdir("../file");
  2. $cmd="./execute-file";
  3. shell_exec($cmd);
  4.  
or
Expand|Select|Wrap|Line Numbers
  1. chdir("../file");
  2. $cmd="./execute-file";
  3. exec($cmd);
  4.  
[Please use CODE tags when posting source code. Thanks! --pbmods]
the output file is created , but nothing in it.
the output file is created and will be edited by the commands in the execute-file.

anyone has any idea , please help.
thanks a million

Tanya
Jun 20 '07 #1
2 2109
pbmods
5,821 Recognized Expert Expert
Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as 'why does this not work?' actually get FEWER responses?).

Heya, Tanya.

So what seems to be the problem?
Jun 20 '07 #2
tanyali
43 New Member
Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as 'why does this not work?' actually get FEWER responses?).

Heya, Tanya.

So what seems to be the problem?
thanks for your answer and the title.

I will describe the problem as much as I can.

firstly, when I execute the script : get_station_dat a on some files( they are GRIB files used in Meteorology ) to get a output file , whose record is like :

2007030412 0 545 0.000000E+00
# Date ID 2010010000

no problem executing the script in a terminal.

because of some reason, I need to execute this script in php.
the code I use (php) is :

chdir("../file"); --change the current dir to the one containing all GRIB files.
$cmd="./get_station_dat a";
shell_exec($cmd );

or

chdir("../file");
$cmd="./get_station_dat a";
exec($cmd);

the result is :
the output files are created , but nothing in it ( should be something there ! )

I just wonder is there anything extra to be done in php to generate & edit a output file instead of just echo the result in a web page .

Looking forward to your answer !
thanks

Tanya
Jun 21 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
3322
by: Sticks | last post by:
ok... im not quite sure how to describe my problem. i have a php script that runs through my entire php site and writes the resulting output to html files. this is necessary as the nature of the hosting available to me for this particular page prohibits me from using php/mysql as i would like. my script works simply by using output buffers and an include the relevant section of code is as follows: ob_start();
4
6857
by: Stan Sainte-Rose | last post by:
Hi guys, I would like to run a vbs script from an asp page. I ve tried many directions but no one works.. The first was : Dim oShell Set oShell = Server.CreateObject("WSCript.shell") i=oShell.run ("w:\wwwroot\look\j_consultation\j06_suivi\modules_stan\GenPDF.vbs 1 2 23,25 byAffaire N 1 FR stan@cyber97.com" )
3
1956
by: James Stroud | last post by:
Hello All, I am helping someone write a python script to run their DOS application through an SSH terminal. It seems that this program wants to access a DOS shell and send output there. If running remotely, this causes a problem because it locks up the program. The program seems (to me) to be looking for some non-existant DOS shell to send its output to. How might I emulate this shell (or whatever it is) with python? I have tried...
1
3482
by: Aaron West | last post by:
Try this script to see what queries are taking over a second. To get some real output, you need a long-running query. Here's one (estimated to take over an hour): PRINT GETDATE() select count_big(*) from sys.objects s1, sys.objects s2, sys.objects s3, sys.objects s4, sys.objects s5 PRINT GETDATE()
1
4114
by: daniel_xi | last post by:
Hi all, I am running a VS 2003 .NET project on my client machine (Win 2000 SP4, ..NET framework 1.1), running an ASP.NET application on a remote web server (Win 2000 Server, IIS 6.0, .NET framework 1.1). The application implements a Progress Bar webcontrol, that pops up in a window, using the HttpHandler interface, on the event of a button click. The handler's process request routine reads the status of the progress by querying the...
4
3757
by: benwylie | last post by:
I am running IIS 6.0 on Windows 2003. I would like to be able to run a perl script from a web page and include the output. I have tried doing it with an ssi: <form action='docsearch.shtml' method='get'> <!--#exec cgi="/cgi-bin/docsearch.pl--> </form> This correctly ran the script, but it was unable to include the
13
6007
by: wattersmt | last post by:
Hello, I am trying to write a python cgi that calls a script over ssh, the problem is the script takes a very long time to execute so Apache makes the CGI time out and I never see any output. The script is set to print a progress report to stdout every 3 seconds but I never see any output until the child process is killed. Here's what I have in my python script:
2
2850
by: Gerard Flanagan | last post by:
Hello, I have a third party shell script which updates multiple environment values, and I want to investigate (and ultimately capture to python) the environment state after the script has run. But running the script as a child process only sets values for that process, which are lost after execution. So I thought I could simply tack on an 'env' command line to the script input lines as shown below. However, using subprocess.Popen gives...
7
6236
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke this shell script using the Subprocess module. Here is my code: def resultFromRunning_(command):
0
10144
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...
1
9937
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8821
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
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
5270
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
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
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.