Jump to content

problem with system() in php.


brainfreeze
 Share

Recommended Posts

Hey everyone, great site.  I can't belive its taken me this long to sign up.

This being my first post and everything, yet the first thing i do is ask a question may be a bit cheeky, but it has to be done! Maybe someone can help.

In some of the episodes i've noticed the lads run commands on windows boxes running apache and php.  Things like turning on winamp etc.

Now i have a linux box with php and apache installed, and i figured the system command would be fairly similar, but it doesn't seem to want to run any program i ask it too.

For example i have:

<html>
<body>

<?php

if(isset($_GET['music']))
{
        if($_GET['music'] == "sexy")
        {
        system("(xmms --play /home/brainfreeze/air.m3u) > null");
        echo "playing -- please wait";    
        }

}

?>

<a href="test.php?music=sexy">sexy</a>
</body>
</html>

yet xmms will not run, even if i use system("xmms"); or system("xmms --play /home/brainfreeze/air. m3u");

however if i do system("ls"); it has no problem displaying me the output, so atleast i know something is being sent to the command line.

What am i doing wrong? Its really boggling my php-noob head.  :(

Link to comment
Share on other sites

Hey, thanks for the reply.

By syntax im assuming your talking about the command rather than the php itself?

"xmms --play /home/brainfreeze/air.m3u" is valid syntax as it works perfectly when i type it into a shell.

To answer your question, when i leave out the ()'s, the result is still the same. xmms (or any other application i've tried so far) doesn't launch. But yet basic commands such as 'ls' etc still do.

Thanks in advance

Link to comment
Share on other sites

See what gets written into that null file, or if this was shorthand for /dev/null then leave that out and see if it spits out any errors over stdout rather than stderr.

Link to comment
Share on other sites

  • 3 weeks later...

Sorry for the late replies guys. I got distracted with what i was trying to achieve with Apache, and bought a Nintendo wii. Since then I've been messing around with the remote.

I'll try out some of the above ideas and, especially the Apache users as that looks the most promising.

I'll get back to shortly.

Jahova.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...