Re: [PHP] CLI: unable to exec shell commands

2005-05-30 Thread Richard Lynch
You should always use a full path to commands and file names in exec,
because you never know what $PATH shell value will be...

You may also be working under some kind of secure enviroment such as a
chroot shell thingie (about which I know almost nothing) or SE Linux (in
which case there should be some kinda file in /etc/ that has a name kinda
like 'selinux' that tells you what's going on) or...

Honestly, though, I'd suggest you make a concerted effort (sooner or
later) to change your scripts to use full paths, even if you get it to
work without them this time around.

On Sat, May 28, 2005 12:42 pm, Andy Pieters said:
 Hi all

 I have several scripts that stoped working.  All those scripts have in
 common
 that they call shell commands.

 To find out what was going on, I did a little test
 cat  ? | php
  ?php
  echo exec test\n;
  exec(dir,$output,$errs);
 ?
 exec test
 sh: /usr/local/php/bin/dir: No such file or directory

 As you can see it is trying to call sh with a weird path.  It should
 use /usr/bin/dir instead

 Also when I try it with 'type' (which is an internal command) it has the
 same
 result.

 I recently switched from FC3 to FC4 for my development.  The PHP binary
 I'm
 using was compiled from sources with the following charasteristics:


 PHP Version = 4.3.10

 Configure Command =  './configure' '--prefix=/usr/local/bin'
 '--bindir=/usr/bin' '--with-mysql' '--with-config-file-path=/etc'
 '--enable-mbstring' '--enable-mbregex' '--with-gd'
 '--enable-gd-native-ttf'
 '--with-ttf-dir=/usr/bin' '--with-freetype-dir=/usr/lib'
 '--with-png-dir=/usr/lib' '--with-xpm-dir=/usr/X11R6' '--enable-ftp'
 '--enable-memory-limit' '--enable-safe-mode' '--enable-bcmath'
 '--enable-calendar' '--enable-ctype' '--enable-inline-optimization'
 '--with-bz2' '--with-iconv' '--with-zlib-dir=/usr/lib' '--disable-cgi'
 '--with-cli'
 Server API = Command Line Interface

 Any ideas?


 With kind regards


 Andy

 --
 Registered Linux User Number 379093
 -- --BEGIN GEEK CODE BLOCK-
 Version: 3.1
 GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++
 L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
 PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
 e$@ h++(*) r--++ y--()
 -- ---END GEEK CODE BLOCK--
 --
 Check out these few php utilities that I released
  under the GPL2 and that are meant for use with a
  php cli binary:

  http://www.vlaamse-kern.com/sas/
 --

 --

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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] CLI: unable to exec shell commands

2005-05-28 Thread Andy Pieters
Hi all

I have several scripts that stoped working.  All those scripts have in common 
that they call shell commands.

To find out what was going on, I did a little test
cat  ? | php
 ?php
 echo exec test\n;
 exec(dir,$output,$errs);
?
exec test
sh: /usr/local/php/bin/dir: No such file or directory

As you can see it is trying to call sh with a weird path.  It should 
use /usr/bin/dir instead

Also when I try it with 'type' (which is an internal command) it has the same 
result.

I recently switched from FC3 to FC4 for my development.  The PHP binary I'm 
using was compiled from sources with the following charasteristics:


PHP Version = 4.3.10

Configure Command =  './configure' '--prefix=/usr/local/bin' 
'--bindir=/usr/bin' '--with-mysql' '--with-config-file-path=/etc' 
'--enable-mbstring' '--enable-mbregex' '--with-gd' '--enable-gd-native-ttf' 
'--with-ttf-dir=/usr/bin' '--with-freetype-dir=/usr/lib' 
'--with-png-dir=/usr/lib' '--with-xpm-dir=/usr/X11R6' '--enable-ftp' 
'--enable-memory-limit' '--enable-safe-mode' '--enable-bcmath' 
'--enable-calendar' '--enable-ctype' '--enable-inline-optimization' 
'--with-bz2' '--with-iconv' '--with-zlib-dir=/usr/lib' '--disable-cgi' 
'--with-cli'
Server API = Command Line Interface

Any ideas?


With kind regards


Andy

-- 
Registered Linux User Number 379093
-- --BEGIN GEEK CODE BLOCK-
Version: 3.1
GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++
L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e$@ h++(*) r--++ y--()
-- ---END GEEK CODE BLOCK--
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/
--

--

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