Re: [PHP] question about executing a bash shell script...

2002-08-16 Thread Robert Cummings

Kelly Meeks wrote:
 
 Hi folks,
 
 I'm learning shell scripting via linux, and have written a script that creates the 
core files necessary for a users website from a master set of files.
 
 Works from the shell just fine (bash makethesite.sh username pathtoputfiles 
pathtogetfiles)
 
 Trying to execute this via php, and it literally does nothing.
 
 If I try something like:
 $bashoutput=shell_exec('bash makethesite.sh username pathtoputfiles pathtogetfiles');
 echo $bashoutput;
 
 I get nothing output, and the script doesn't execute.


I'm asuming you are executing something like the following:

php myPhpScript.php

The following will probably give you the desired results...

php -qC myPhpScript.php

This prevents PHP from switching out of the current directory.

HTH,
Rob.
-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] question about executing a bash shell script...

2002-08-16 Thread James E Hicks III

try something like:
$bashoutput=shell_exec('/usr/bin/bash makethesite.sh username pathtoputfiles
pathtogetfiles');

if that doesn't work can you use the system() function instead?

James


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] question about executing a bash shell script...

2002-08-16 Thread Kelly Meeks

Hi Robert,

Thanks so much for the prompt reply.

Actually, I'm not trying to execute a php script, I'm trying to execute a
shell (bash) script.

This works at the command line:
bash makethesite.sh param1 param2 param3

This doesn't work via php
$bashresult=shell_exec('bash makethesite.sh param1 param2 param3');
echo $bashresult;

Doesn't execute the script, nothing in $bashresult

Kelly
- Original Message -
From: Robert Cummings [EMAIL PROTECTED]
To: Kelly Meeks [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, August 16, 2002 4:44 PM
Subject: Re: [PHP] question about executing a bash shell script...


 Kelly Meeks wrote:
 
  Hi folks,
 
  I'm learning shell scripting via linux, and have written a script that
creates the core files necessary for a users website from a master set of
files.
 
  Works from the shell just fine (bash makethesite.sh username
pathtoputfiles pathtogetfiles)
 
  Trying to execute this via php, and it literally does nothing.
 
  If I try something like:
  $bashoutput=shell_exec('bash makethesite.sh username pathtoputfiles
pathtogetfiles');
  echo $bashoutput;
 
  I get nothing output, and the script doesn't execute.


 I'm asuming you are executing something like the following:

 php myPhpScript.php

 The following will probably give you the desired results...

 php -qC myPhpScript.php

 This prevents PHP from switching out of the current directory.

 HTH,
 Rob.
 --
 .-.
 | Robert Cummings |
 :-`.
 | Webdeployer - Chief PHP and Java Programmer  |
 :--:
 | Mail  : mailto:[EMAIL PROTECTED] |
 | Phone : (613) 731-4046 x.109 |
 :--:
 | Website : http://www.webmotion.com   |
 | Fax : (613) 260-9545 |
 `--'



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] question about executing a bash shell script...

2002-08-16 Thread Robert Cummings

Kelly Meeks wrote:
 
 Hi Robert,
 
 Thanks so much for the prompt reply.
 
 Actually, I'm not trying to execute a php script, I'm trying to execute a
 shell (bash) script.
 
 This works at the command line:
 bash makethesite.sh param1 param2 param3
 
 This doesn't work via php
 $bashresult=shell_exec('bash makethesite.sh param1 param2 param3');
 echo $bashresult;

You are trying to execute a bash script from PHP though. When you invoke
the php engine it usually changes directory (to the root defined in the
php.ini I think). To stop this so that it will remain in the current
directory so that when you run bash it will see the bash script in the
current directory, you need to use the -C command line option. I believe
your environment is inherited by php and subsequently bash and so if
you don't use the -C option bash will be looking in the wrong directory.

Cheers,
Rob.

 
 Doesn't execute the script, nothing in $bashresult
 
 Kelly
 - Original Message -
 From: Robert Cummings [EMAIL PROTECTED]
 To: Kelly Meeks [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Friday, August 16, 2002 4:44 PM
 Subject: Re: [PHP] question about executing a bash shell script...
 
  Kelly Meeks wrote:
  
   Hi folks,
  
   I'm learning shell scripting via linux, and have written a script that
 creates the core files necessary for a users website from a master set of
 files.
  
   Works from the shell just fine (bash makethesite.sh username
 pathtoputfiles pathtogetfiles)
  
   Trying to execute this via php, and it literally does nothing.
  
   If I try something like:
   $bashoutput=shell_exec('bash makethesite.sh username pathtoputfiles
 pathtogetfiles');
   echo $bashoutput;
  
   I get nothing output, and the script doesn't execute.
 
 
  I'm asuming you are executing something like the following:
 
  php myPhpScript.php
 
  The following will probably give you the desired results...
 
  php -qC myPhpScript.php
 
  This prevents PHP from switching out of the current directory.
 
  HTH,
  Rob.
  --
  .-.
  | Robert Cummings |
  :-`.
  | Webdeployer - Chief PHP and Java Programmer  |
  :--:
  | Mail  : mailto:[EMAIL PROTECTED] |
  | Phone : (613) 731-4046 x.109 |
  :--:
  | Website : http://www.webmotion.com   |
  | Fax : (613) 260-9545 |
  `--'
 

-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] question about executing a bash shell script...

2002-08-16 Thread Jason Wong

On Saturday 17 August 2002 04:35, Kelly Meeks wrote:
 Hi folks,

 I'm learning shell scripting via linux, and have written a script that
 creates the core files necessary for a users website from a master set of
 files.

 Works from the shell just fine (bash makethesite.sh username pathtoputfiles
 pathtogetfiles)

 Trying to execute this via php, and it literally does nothing.

 If I try something like:
 $bashoutput=shell_exec('bash makethesite.sh username pathtoputfiles
 pathtogetfiles'); echo $bashoutput;

 I get nothing output, and the script doesn't execute.

What does the php logs say? You should set error_reporting to E_ALL.

 Any ideas?

The user that the webserver (assuming apache) is usually nobody or apache and 
may not have the necessary permissions to execute your script. Also try 
specifying the complete path to bash.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Those who educate children well are more to be honored than parents, for
these only gave life, those the art of living well.
-- Aristotle
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php