You are here: Running Shell Scripts « PHP Programming Language « IT news, forums, messages
Running Shell Scripts

Posted by paulhjwu@gmail.com on 02/01/06 19:11

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: "paulhjwu@gmail.com" <paulhjwu@gmail.com>
To: gmuldoon <gmuldoon_nospam@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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация