473,566 Members | 3,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running Shell Scripts

Hi,

I have problems running a couple of shell scripts from PHP. I found a
similar
posting, so I posted my question to the original author. But
unfortunately the
original author is not at the address anymore. Anyone can help with the
problems
highlghted below?

Many Thanks,
Paul
---------- Forwarded message ----------
From: "pa******@gmail .com" <pa******@gmail .com>
To: gmuldoon <gm************ *@scu.edu.au>
Date: Wed, 01 Feb 2006 16:55:49 +0000
Subject: Re: Problem calling a shell script

gmuldoon wrote:
Help please.

Setup: RH EL3, PHP 4.3.5, Apache 1.3.29 running as user "nobody".

Have a bash script named shell_script.

Telnet to server as user "nobody" ("nobody" having been given /bin/bash
as temp shell), can run this script from command line, no problems.

Created a php script including the line:
system ("/path/to/shell_script");
but get error message in apache error logs:
/bin/bash: /root/.bashrc: Permission denied

Appears that PHP is using root environment rather than "nobody" env?
phpinfo seems to list env vars for root under the "Environmen t" section.

Will compiling PHP as "nobody" instead of root solve or cause other
probs?


Hi, I have a similar problem now. I am wondering whether you have found
solution to the above. My script looks like the following:

$cmd =
"export JAVA_HOME=/usr/java/jdk1.5.0\n" .
"cd /opt/softwares/archive_system/nutchwax\n" .
"ls -l\n" .
"/bin/sh bin/indexarcs.sh -d
/opt/softwares/archive_system/archive_data/nutch -s
/opt/softwares/archive_system/archive_data/heritrix -n\n" .
"cd /opt/softwares/archive_system/archive_data/nutch\n"
..
"ls -l\n" .
"/bin/sh
/usr/tomcat/jakarta-tomcat-5.5.8/bin/catalina.sh stop\n" .
"/bin/sh
/usr/tomcat/jakarta-tomcat-5.5.8/bin/catalina.sh start\n" ;

$fp = popen($cmd, 'r');
$read = fread($fp, 10240);
flush();
echo $read;
pclose($fp);

However, it seems it would run until the first "ls -l", but it got
stuck on the "/bin/sh bin/indexarcs.sh ..." step. The bin/indexarcs.sh
has around 300 lines of sh commands.

Thanks,
Paul

Feb 1 '06 #1
0 1678

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

Similar topics

3
2000
by: Rob Ristroph | last post by:
I'm helping someone who is running a server with Debian testing, which only has PHP 4.2.3, not higher. He wants to run php from the command line, which I think is only supported starting with 4.3. Is there a way to do it with 4.2.3 ? I am trying to avoid installing a newer version of php from source, as the machine has a running webserver...
3
9763
by: Dung Nguyen | last post by:
Hi. Is there a way to execute PL/SQL scripts from PHP? I have PL/SQL scripts that utilizes the DBMS_xxx packages. Is it possible to shell out a command that will run the PL/SQL? -DN
2
3358
by: eichin | last post by:
One of my recent projects has involved taking an accretion of sh and perl scripts and "doing them right" - making them modular, improving the error reporting, making it easier to add even more features to them. "Of course," I'm redoing them in python - much of the cut&paste reuse has become common functions, which then get made more robust...
2
14344
by: Jorgen Grahn | last post by:
I couldn't think of a good solution, and it's hard to Google for... I write python command-line programs under Win2k, and I use the bash shell from Cygwin. I cannot use Cygwin's python package because of a binary module which has to be compiled with Visual C 6. My scripts start with a '#!/usr/bin/env python' shebang, as God intended. ...
9
3647
by: Jeff Wagner | last post by:
I have a project of converting numerous DOS cmd shell scripts to Python. Is there a tutorial to getting started? Thanks, Jeff
2
4852
by: Dave Hughes | last post by:
Just noticed something rather annoying after upgrading my test box (a Linux server running DB2 UDB v8 for LUW) to fixpak 11 (for reference it was previously on fixpak 7). In the past I've relied heavily on the ability to start multiple long-running SQL scripts in the background and have them all run in parallel. Unfortunately, it seems that...
24
2823
by: Mark | last post by:
Hi, I'm new to python and looking for a better idiom to use for the manner I have been organising my python scripts. I've googled all over the place about this but found absolutely nothing. I'm a linux/unix command line guy quite experienced in shell scripts etc. I have a heap of command line utility scripts which I run directly. What is...
1
3315
by: creeds | last post by:
Hello , I am thinking of performing databse operation using shell scripts , for example i am in need to delete sum number from database very often so if i just run a shell scripts and give that number and if it gets deleted, it will be a quiter easy. thinking that i am trying to do shuch scripts, i am looking in the net and now can perform sum...
7
6213
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
7673
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
7893
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. ...
1
7645
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
7953
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
6263
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...
0
5213
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
3643
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2085
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

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.