|
-
May 20th, 2009, 10:17 PM
#1
Thread Starter
Fanatic Member
Run a linux script from a PHP file!
I know this should frikkin work but it's been pissing me off all night and I can't figure it out. I'm using shell_exec('/media/<....>/mine/script.sh'); and IT WILL NOT RUN RIGHT!!!
If I echo that command and put a return in the script, it outputs that return line. There seems to be NO errors running anything. WFT is the problem?? I've chmod'd 777 to the file, tried changing the file owner to root and nobody and NOTHING WORKS!!!! Can anyone explain why?
Latest Apache/PHP5, Ubuntu Linux
BTW the script is 3 lines really and it runs fine in a terminal on the server.
import -window root /media/disk/apache2dir/mine/screenshot.png
echo This should have ****ing worked!!
exit
Visit here to learn to make the VB interface fit you!.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison 
"The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge
-
May 21st, 2009, 12:14 AM
#2
Re: Run a linux script from a PHP file!
I'm sorry but your question confuses me.
What do you expect to happen?
-
May 21st, 2009, 05:57 AM
#3
Thread Starter
Fanatic Member
Re: Run a linux script from a PHP file!
It should run a script (screenshot.sh) and that script will take a screenshot and save it to /media/disk/apache2dir/mine/screenshot.png, then my script will redirect to that screenshot png. The idea of the whole thing is to be able to see a screenshot on my server from anywhere I want.
EDIT
OK, I've also determined that changing the owner does nothing. Also, CRON cannot run the job either. It seems ONLY to run when used at the command line. Any ideas anyone?
Last edited by ididntdoit; May 21st, 2009 at 04:02 PM.
Visit here to learn to make the VB interface fit you!.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison 
"The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge
-
May 24th, 2009, 02:19 AM
#4
Fanatic Member
Re: Run a linux script from a PHP file!
When you run it from command prompt, are you using sudo, or the command prompt is root's?
I only know a little about Linux, but it's the only thing I can think of.
-
May 24th, 2009, 08:51 PM
#5
Thread Starter
Fanatic Member
Re: Run a linux script from a PHP file!
no sudo. But it does work with sudo.
Visit here to learn to make the VB interface fit you!.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison 
"The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge
-
May 29th, 2009, 10:16 PM
#6
Thread Starter
Fanatic Member
Re: Run a linux script from a PHP file!
OK FYI it turns out that Cron and PHP do not by default have access to the X server in linux. To make my script (below) work with Cron, you must include a path to the DISPLAY environment variable. I think the reason that doesn't solve the PHP problem is that PHP has some issues with security when it comes to linux. I'm not quite sure how to address them.
Does anyone know?
Code:
#!/bin/bash
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DISPLAY=:0
export DISPLAY;
HOME=/home/browner87
export HOME;
/usr/bin/import -display :0.0 -window root -silent /media/disk/thepath/screenshot.png
Visit here to learn to make the VB interface fit you!.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison 
"The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|