Re: [PHP] shell_exec with pipes

2003-11-16 Thread Jason Wong
On Thursday 13 November 2003 16:51, Mario Ohnewald wrote:

[snip]

 ==
 Checking audio filter chain for 44100Hz/2ch/16bit - 44100Hz/2ch/16bit...
 AF_pre: af format: 2 bps, 2 ch, 44100 hz, little endian signed int
 AF_pre: 44100Hz 2ch Signed 16-bit (Little-Endian)
 audio_setup: Can't open audio device /dev/dsp: Permission denied
 AO: [null] 44100Hz 2ch Signed 16-bit (Little-Endian) (2 bps)
 Building audio filter chain for 44100Hz/2ch/16bit - 44100Hz/2ch/16bit...
 Starting playback...


 Exiting... (End of
 file)

 ---
---


 So php kind of exits after the == chars.
 Any further ideas?

Let's try a change of tack. I believe you wanted to extract some info from an 
MPEG file? So look for a program which does simply that, ie without trying to 
play the damn thing. There is a project based on PHP which extracts various 
info from various format multimedia files. That may or may not do what you 
want. You can find it on freshmeat.net. 

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Don't get mad, get even.
-- Joseph P. Kennedy

Don't get even, get jewelry.
-- Anonymous
*/

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



Re: [PHP] shell_exec with pipes

2003-11-13 Thread Jason Wong
On Wednesday 12 November 2003 21:48, Mario Ohnewald wrote:

 ok, i am running the script like this now:

[snip]

This seems to suggest that shell_exec() does not like your command and is not 
executing it, so:

Try tackling it logically, step-by-step:

  Have you:
 
  1) Turned on full error reporting?

 How do i turn that on?

In php.ini, once you've enabled it, restart webserver and see what errors, if 
any, you get.

  2) Checked that (i) you're not running in safe_mode, or (ii) if you are,
  that
  you are allowed to access those executables?

 i am running in safe mode.

What is the answer to (ii)?

Are you able to execute any shell programs/commands at all? Hint try something 
simple like shell_exec('touch /tmp/testfile') and see whether /tmp/testfile 
is being created.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
I can't stand squealers; hit that guy.
-- Albert Anastasia
*/

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



Re: [PHP] shell_exec with pipes

2003-11-13 Thread Mario Ohnewald
Hello!
I think we are almost there yet :)

 On Wednesday 12 November 2003 21:48, Mario Ohnewald wrote:
 
  ok, i am running the script like this now:
 
 [snip]
 
 This seems to suggest that shell_exec() does not like your command and is
 not 
 executing it, so:
 
 Try tackling it logically, step-by-step:
 
   Have you:
  
   1) Turned on full error reporting?
 
  How do i turn that on?
 
 In php.ini, once you've enabled it, restart webserver and see what errors,
 if 
 any, you get.
ok, i have enabled that with error_reporting(E_ALL); 

 
   2) Checked that (i) you're not running in safe_mode, or (ii) if you
 are,
   that
   you are allowed to access those executables?
 
  i am running in safe mode.
 
 What is the answer to (ii)?
Yes, i do have acces to those files and the permissions are correct.

 
 Are you able to execute any shell programs/commands at all? Hint try
 something 
 simple like shell_exec('touch /tmp/testfile') and see whether
 /tmp/testfile 
 is being created.
Yes, i am. 

I think the key is here somewhere:
PHP Output from shell_exec(/usr/local/bin/mplayer -identify -frames 0
/tmp/pitstop.mpeg);


MPlayer 1.0pre2-3.3.2 (C) 2000-2003 MPlayer Team

CPU: Advanced Micro Devices Athlon MP/XP Thoroughbred 1466 MHz (Family: 6,
Stepping: 1)
Detected cache-line size is 64 bytes
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE

Reading config file /usr/local/etc/mplayer/mplayer.conffont: can't open
file: (null)
font: can't open file: /usr/local/share/mplayer/font/font.desc
Using usleep() timing

Playing /tmp/pitstop.mpeg
MPEG-PS file format detected.
VIDEO:  MPEG1  320x240  (aspect 1)  29.970 fps  1151.2 kbps (143.9 kbyte/s)



PHP Output from normal shell /usr/local/bin/mplayer -identify -frames 0
/tmp/pitstop.mpeg

MPlayer 1.0pre2-3.3.2 (C) 2000-2003 MPlayer Team

CPU: Advanced Micro Devices Athlon MP/XP Thoroughbred 1466 MHz (Family: 6,
Stepping: 1)
Detected cache-line size is 64 bytes
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE

Reading config file /usr/local/etc/mplayer/mplayer.conf: No such file or
directory
Reading config file /home/lansinplayer/.mplayer/config
Reading /home/lansinplayer/.mplayer/codecs.conf: Can't open
'/home/lansinplayer/.mplayer/codecs.conf': No such file or directory
Reading /usr/local/etc/mplayer/codecs.conf: Can't open
'/usr/local/etc/mplayer/codecs.conf': No such file or directory
Using built-in default codecs.conf
font: can't open file: /home/lansinplayer/.mplayer/font/font.desc
font: can't open file: /usr/local/share/mplayer/font/font.desc
Failed to open /dev/rtc: Permission denied (mplayer should be setuid root or
/dev/rtc should be readable by the user.)
Using usleep() timing
Can't open input config file /home/lansinplayer/.mplayer/input.conf: No such
file or directory
Can't open input config file /usr/local/etc/mplayer/input.conf: No such file
or directory
Falling back on default (hardcoded) input config

Playing /tmp/pitstop.mpeg
MPEG-PS file format detected.
VIDEO:  MPEG1  320x240  (aspect 1)  29.970 fps  1151.2 kbps (143.9 kbyte/s)
==
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
MP3lib: init layer23 finished, tables done
AUDIO: 44100 Hz, 2 ch, 16 bit (0x10), ratio: 16000-176400 (128.0 kbit)
Selected audio codec: [mp3] afm:mp3lib (mp3lib MPEG layer-2, layer-3)
==
ID_FILENAME=/tmp/pitstop.mpeg
ID_VIDEO_FORMAT=0x1001
ID_VIDEO_BITRATE=1151200
ID_VIDEO_WIDTH=320
ID_VIDEO_HEIGHT=240
ID_VIDEO_FPS=29.970
ID_VIDEO_ASPECT=0.
ID_AUDIO_CODEC=mp3
ID_AUDIO_FORMAT=80
ID_AUDIO_BITRATE=128000
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=2
ID_LENGTH=16
vo: couldn't open the X11 display ()!
vo: couldn't open the X11 display ()!
VO XOverlay need a subdriver
vo: couldn't open the X11 display ()!
Can't open /dev/fb0: Permission denied
[fbdev2] Can't open /dev/fb0: Permission denied
==
Opening video decoder: [mpegpes] MPEG 1/2 Video passthrough
VDec: vo config request - 320 x 240 (preferred csp: Mpeg PES)
VDec: using Mpeg PES as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
VO: [null] 320x240 = 320x240 Mpeg PES
Selected video codec: [mpegpes] vfm:mpegpes (Mpeg PES output (.mpg or
Dxr3/DVB card))
==
Checking audio filter chain for 44100Hz/2ch/16bit - 44100Hz/2ch/16bit...
AF_pre: af format: 2 bps, 2 ch, 44100 hz, little endian signed int
AF_pre: 44100Hz 2ch Signed 16-bit (Little-Endian)
audio_setup: 

RE: [PHP] shell_exec with pipes

2003-11-12 Thread Mario Ohnewald
Hi,

 $var=shell_exec(/usr/local/bin/mplayer -identify -frames 0
 /tmp/pitstop.mpeg 2/dev/null | grep ID_LENGTH | cut -d \=\ -f 2);

$var=shell_exec(/usr/local/bin/mplayer -identify -frames 0
/tmp/pitstop.mpeg 2/dev/null | grep ID_LENGTH | cut -d \=\ -f 2);
echo Output: $var;

Still gives nothing back :/
Told you, its not that easy :P


Thank you very much, Mario

-- 
NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse für Mail, Message, More! +++

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



Re: [PHP] shell_exec with pipes

2003-11-12 Thread Jason Wong
On Wednesday 12 November 2003 17:21, Mario Ohnewald wrote:

  $var=shell_exec(/usr/local/bin/mplayer -identify -frames 0
  /tmp/pitstop.mpeg 2/dev/null | grep ID_LENGTH | cut -d \=\ -f 2);

 $var=shell_exec(/usr/local/bin/mplayer -identify -frames 0
 /tmp/pitstop.mpeg 2/dev/null | grep ID_LENGTH | cut -d \=\ -f 2);
 echo Output: $var;

 Still gives nothing back :/
 Told you, its not that easy :P

Have you:

1) Turned on full error reporting?
2) Checked that (i) you're not running in safe_mode, or (ii) if you are, that 
you are allowed to access those executables?
3) Confirmed that the left side of the pipe is working and giving the expected 
output?
4) Tried giving the full path to grep?

If you're still having trouble with it you can try sticking the above into a 
little shell script and shell_exec() the shell script instead.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Due to lack of disk space, this fortune database has been discontinued.
*/

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



Re: [PHP] shell_exec with pipes

2003-11-12 Thread Mario Ohnewald
ok, i am running the script like this now:
 START -

$var=shell_exec(/home/lansinplayer/server/apache/htdocs/lansinplayer/getfilelength.sh 
/tmp/pitstop.mpeg);
echo --$var--;
 STOP -
Where echo returns nothing. I did a chmod 777 on the getfilelength.sh file.


When i run the file in shell i get this:
$ /home/lansinplayer/server/apache/htdocs/lansinplayer/getfilelength.sh
/tmp/pitstop.mpeg
16


The Shell file looks like that:
if [ $1 ];then
length=`mplayer -identify -frames 0 $1 2/dev/null| grep ID_LENGTH
| cut -d \=\ -f 2`
echo $length





 On Wednesday 12 November 2003 17:21, Mario Ohnewald wrote:
 
   $var=shell_exec(/usr/local/bin/mplayer -identify -frames 0
   /tmp/pitstop.mpeg 2/dev/null | grep ID_LENGTH | cut -d \=\ -f 2);
 
  $var=shell_exec(/usr/local/bin/mplayer -identify -frames 0
  /tmp/pitstop.mpeg 2/dev/null | grep ID_LENGTH | cut -d \=\ -f 2);
  echo Output: $var;
 
  Still gives nothing back :/
  Told you, its not that easy :P
 
 Have you:
 
 1) Turned on full error reporting?
How do i turn that on?

 2) Checked that (i) you're not running in safe_mode, or (ii) if you are,
 that 
 you are allowed to access those executables?
i am running in safe mode.

 3) Confirmed that the left side of the pipe is working and giving the
 expected 
 output?
$var2=shell_exec(mplayer -identify -frames 0 /tmp/pitstop.mpeg | /bin/grep
ID_LENGTH);
gives nothing back.

Thats what i get in Shell:
-
$ mplayer -identify -frames 0 /tmp/pitstop.mpeg | grep ID_LENGTH
: No such file or directory
Can't open '/home/lansinplayer/.mplayer/codecs.conf': No such file or
directory
Can't open '/usr/local/etc/mplayer/codecs.conf': No such file or directory
Failed to open /dev/rtc: Permission denied (mplayer should be setuid root or
/dev/rtc should be readable by the user.)
Can't open input config file /home/lansinplayer/.mplayer/input.conf: No such
file or directory
Can't open input config file /usr/local/etc/mplayer/input.conf: No such file
or directory
Falling back on default (hardcoded) input config
vo: couldn't open the X11 display ()!
vo: couldn't open the X11 display ()!
VO XOverlay need a subdriver
vo: couldn't open the X11 display ()!
Can't open /dev/fb0: Permission denied
[fbdev2] Can't open /dev/fb0: Permission denied
audio_setup: Can't open audio device /dev/dsp: Permission denied
ID_LENGTH=16



 4) Tried giving the full path to grep?
yes i did
 
 If you're still having trouble with it you can try sticking the above into
 a 
 little shell script and shell_exec() the shell script instead.
See above.


Any further ideas?

Thank you, Mario

-- 
NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse für Mail, Message, More! +++

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



Re: [PHP] shell_exec with pipes

2003-11-11 Thread Aaron Gould
Have you tried escaping the pipes and quotes?  Try this:

$var=shell_exec(/usr/local/bin/mplayer -identify -frames 0 
/tmp/pitstop.mpeg 2/dev/null\| grep ID_LENGTH \| cut -d \=\ -f 2);

Mario Ohnewald wrote:

$var=shell_exec(/usr/local/bin/mplayer -identify -frames 0
/tmp/pitstop.mpeg 2/dev/null| grep ID_LENGTH | cut -d = -f 2);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] shell_exec with pipes

2003-11-11 Thread Mario Ohnewald
 Have you tried escaping the pipes and quotes?  Try this:
 
 $var=shell_exec(/usr/local/bin/mplayer -identify -frames 0 
 /tmp/pitstop.mpeg 2/dev/null\| grep ID_LENGTH \| cut -d \=\ -f 2);

nope, still get nothing back.

 
 Mario Ohnewald wrote:
 
  $var=shell_exec(/usr/local/bin/mplayer -identify -frames 0
  /tmp/pitstop.mpeg 2/dev/null| grep ID_LENGTH | cut -d = -f 2);
 

-- 
NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse für Mail, Message, More! +++

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



RE: [PHP] shell_exec with pipes

2003-11-11 Thread Jay Blanchard
[snip]
 $var=shell_exec(/usr/local/bin/mplayer -identify -frames 0 
 /tmp/pitstop.mpeg 2/dev/null\| grep ID_LENGTH \| cut -d \=\ -f 2);
[/snip]

$var=shell_exec(/usr/local/bin/mplayer -identify -frames 0
/tmp/pitstop.mpeg 2/dev/null | grep ID_LENGTH | cut -d \=\ -f 2);

Try just escaping the quotes, pipes should be OK IIRC.

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