Jump to content

Shell Command in PHP

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1
john_robot

john_robot

    Newbie

  • Members
  • Pip
  • 5 posts
Hi,

Pls tell me how to code this shell command in PHP

( echo "RGBA32 88 31 20 25 0 1" ; cat /var/www/vhosts/lankaclipstv.com/httpdocs/mylogo.rgba ) > /var/www/vhosts/lankaclipstv.com/httpdocs/mylogo.fifo &



<?php


echo shell_exec('( echo "RGBA32 197 32 120 205 0 1" ; cat /var/www/vhosts/lankaclipstv.com/httpdocs/mylogo.rgba ) > /var/www/vhosts/lankaclipstv.com/httpdocs/mylogo.fifo &');

?> 




I tried above but it seems not working no output.

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
there are no output as you redirect your output to the fifo file ( the > char does this)

but then, my thoughts goes to the parentheses, if you really can do it that way, almost believe that you can not, but i'm not certain.

and now, i think of the ampersand in the end, witch batches the execution, and therefore, the output will never be caught back that way either. It starts the command and lets the command ran run until it's finished.

I believe you need to try this out first on a linux machine.

#3
john_robot

john_robot

    Newbie

  • Members
  • Pip
  • 5 posts
ok Thank you next thing is this SSH command its working fine on the command prompt(file converting). but not working in PHP. ( the file not converting)

mencoder -oac copy -vf bmovl=0:0:mylogo.fifo -ovc raw -o t2.mpg t1.mpg

Quote

<?php
echo shell_exec('/usr/bin/mencoder -oac copy -vf bmovl=0:0:/var/www/vhosts/lankaclipstv.com/httpdocs/mylogo.fifo -ovc raw -o /var/www/vhosts/lankaclipstv.com/httpdocs/t2.mpg /var/www/vhosts/lankaclipstv.com/httpdocs/t1.mpg');
?>

what do i have to do to fix this ?

#4
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
sounds like a rights problem to me. does webserver user has execute rights on mencoder binary?

#5
john_robot

john_robot

    Newbie

  • Members
  • Pip
  • 5 posts
[~] # ll /usr/bin/mencoder
-rwxr-xr-x 1 root root 7653556 Nov 10 07:44 /usr/bin/mencoder

yes it has.

#6
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
what happens when you do
echo shell_exec('/usr/bin/mencoder');

and, is your php in safe mode? then shell_exec won't work, but i hope that throws an error...

#7
john_robot

john_robot

    Newbie

  • Members
  • Pip
  • 5 posts
HI, then it gives me this

MEncoder 1.0rc2-4.1.2 © 2000-2007 MPlayer Team CPU: AMD Athlon™ 64 X2 Dual Core Processor 4600+ (Family: 15, Model: 75, Stepping: 2) CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1 Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2 115 audio & 237 video codecs Exiting... (error parsing command line)

----------------
safe_mode Off
what I am doing wrong ?

#8
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
do you find anything about the file you convert to, does anything happen to it? delete it and try again, does it create the file then?

after your shell_exec, make a echo and see if you'll see that on page...
that means the execution has been done.

have you timed the conversion when you run it by hand? it might be a php timeout...

#9
john_robot

john_robot

    Newbie

  • Members
  • Pip
  • 5 posts
No its simply not converting. there is no t2.mpg file to delete.

how to make another echo ? sorry I am very new to programming. :(

when I try this in command prompt its executing in a minute and i see that t2.mpg file created. From the PHP page; it just give me the above results page in a second. page wont timed out.

#10
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
on a new line after your shell_exec and before ?>

echo "after shell_exec<br />";

you could also do similar before (and set that text aswell) to see that your page does give output

what you could do aswell is putting this at the shell_exec:

echo "Mencoder ". shell_exec()."<br />;
and fill the parentheses as usual.. do mind the dot, it's needed, it writes the text mencoder on that line and then eventual output.


by the way, do you have the <html>, <head></head> and <body> tags in your file before the <?php and the </body></html> tags after your ?>
??

#11
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
You could use <p></p> tags instead of <br> tags.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums