Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 12-09-2005, 10:12 PM   #1
Registered: Dec 2005
Location: TO, Ontario, Canada
Distribution: Ubuntu 14.04, CentOS 6.5
Posts: 37

Rep: Reputation: 17
PHP / VideoLAN / Fedora Core Question - how can I get the PHP "exec" function to work

Hi All,

this is my first post in any forum, period! In fact, so far, any of my questions have been asked before and I could google the answer. This time I am stuck!

Here is my project: I wanted to stream my TV signal over the network, so that any of the computers attached could watch TV without having a TV Tuner card in it.

My solution so far: I put together an old P3-550 with a ATI TV Wonder Card, installed Fedora Core 4 & VideoLAN. I use XAWTV to set the channel I want to watch and let VideoLAN stream the signal. I installed KDE, but am using IceWM on it, since it is much leaner. I also access the box through VNC, which I have been using to change the channel.

What I wanted to do next: I wanted to write a quick PHP script (make it look like a remote control) to change the channels. There is a way to change the channel, through "xawtv-remote". The command is "xawtv-remote setchannel next" or "prev" or the number of the channel. Very simple really.

My Dilema: Well, I thought this would be real easy. Just write a PHP code like this:

if (isset($_POST["check"])) {
if ($_POST["channel"] == "Up") {
echo exec('/usr/bin/xawtv-remote setchannel next');
if ($_POST["channel"] == "Down") {
echo exec('usr/bin/xawtv-remote setchannel prev');
if ($_POST["channelnumber"] != "") {
echo exec('usr/bin/xawtv-remote setchannel '.$_POST["channelnumber"]);
<FORM method="POST" action="">
<INPUT value="send" name="check" type="hidden">
<INPUT type="submit" name="channel" value="Down"><br>
<INPUT type="submit" name="channel" value="Up"><br>
Or enter Channel #: <INPUT type="text" name="channelnumber" value="<?php if (isset($_POST["check"])) {
echo $_POST["channelnumber"];
?>"><INPUT type="submit" name="submit" value="Set"><br> </FORM>

Now, all I get is an output of "1", evertime I send the channel change, but the channel doesn't change. If I type that command in a Terminal it does what it's suppossed to do.
I know that the command is proper (I played with it for hours, taking away the complete path, moving the file, changing the privileges of the file, etc.)
I even gave apache root privileges (so I think. I am unsure if I did it correctly, since it didn't work).
Well, I tried different PHP commands, such as "system", but nothing. I am not sure where the error lies, since it doesn't really give me an error, just "1".
I went and checked to see if the PHP.ini had anything turn on that would prevent the script from executing, but I know exec works, since I can "ls" the directory and get the files.
Then I went and checked the apache httpd.conf file to see if there is something amiss, but again, couldn't find anything. I even tried the "sudo" thing, changing the permissions with visudo.
Really, what is left to do?????????

I am up to try anything. If you have any clue what may be the problem here, let me know.


Last edited by gtrawoger; 12-09-2005 at 10:14 PM.
Old 12-16-2005, 02:50 PM   #2
Senior Member
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
First of all: you have a typo:
if ($_POST["channel"] == "Down") {
 echo exec('usr/bin/xawtv-remote setchannel prev');
 if ($_POST["channelnumber"] != "") {
 echo exec('usr/bin/xawtv-remote setchannel '.$_POST["channelnumber"]);
Those need to have "/" prepended...

Second: if you have "safe mode" on then you need to put anything you want to "exec" into safe_mode_exec_dir (see php.ini)

When I run your script on my system i get:
sh: /etc/apache2/bin/xawtv-remote: No such file or directory
Which is expected, as I have no "xawtv-remote" in my safe exec dir "/etc/apache2/bin/"

So: either turn off safe mode (not a good idea if server is publically accessable) or put the command in your safe_mode_exec_dir, or make whatever directory the program is in your safe_mode_exec_dir (again, not good security wize...)

Old 12-21-2005, 06:49 AM   #3
Registered: Dec 2005
Location: TO, Ontario, Canada
Distribution: Ubuntu 14.04, CentOS 6.5
Posts: 37

Original Poster
Rep: Reputation: 17
Ok, here is an update (sorry it took so long, I do not have too much time to put into this)....

I finally (after this last post) took a look into the apache error log, and guess what? I found the error messages I needed to see (instead of simply getting "1")....

It spits out "can't get display" when I call on the exec function. Which is great in some way, since this is a xawtv-remote error message, pointing toward that the exec function IS working.

Now, next issue is to figure out how to get the apache user to use the xawtv-remote program to change xawtv station that is running on user "tv".

Would I be using "sudo" on this? Can anybody help me there????

Old 12-21-2005, 06:51 AM   #4
Registered: Dec 2005
Location: TO, Ontario, Canada
Distribution: Ubuntu 14.04, CentOS 6.5
Posts: 37

Original Poster
Rep: Reputation: 17
oh... I forgot... bulliver.... thanks for the reply. It did send me the right way!!!!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fedora Core 2: Screen Resolution can not change from "800X600" to "1024X 768" suhaimi_sj Fedora - Installation 18 12-17-2009 03:29 AM
No UTMPX entry, You must EXEC "login" for the lowest "shell" ooihc Solaris / OpenSolaris 7 03-12-2007 02:09 PM
Php or Mysql upgrade on Fedora Core 2 "Uptodate" Program geninblaze Fedora 1 07-12-2004 09:56 PM
Help php exec, system function for compile javac or java antony_csf Programming 0 06-15-2004 01:45 AM
php ide with "break" and "trace" Kayaker Programming 3 04-25-2003 02:52 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:29 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration