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

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 "Environment" 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 1641

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

Similar topics

3
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....
3
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
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...
2
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...
9
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
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...
24
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...
1
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...
7
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
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.