Problemas launching firefox from a script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm developing a prototype of a multimedia Linux kiosk.

When the kiosk starts, it launches Firefox in fullscreen mode. It's
fine.

Then, i have a script in PERL called every 10 minutes by the cron daemon
to check if the kiosk has connection to the internet or not.
So, i test every 10 minutes the state of the conection.
If the state changes, i want to run Firefox with a different page.

The problem is that if i launch the script from a X terminal, everything
is ok.
When called by the cron daemon i get this error:

"Failed to conect to X server"

I'm running Mandrake 10.0 / WindowMaker / X 4.3.0.1

I sent you my PERL script and my crontab file so that you can evaluate
what's going on.

I've already run "xhost +" and "export DISPLAY=:0.0", but no good :(

Any help would be appreciated.

Thanks in advance.

Warm Regards,
Mário Gamito










SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root nice -n 19 run-parts /etc/cron.hourly
02 4 * * * root nice -n 19 run-parts /etc/cron.daily
22 4 * * 0 root nice -n 19 run-parts /etc/cron.weekly
42 4 1 * * root nice -n 19 run-parts /etc/cron.monthly
*/10 * * * * mario /etc/script_kiosk.pl 

#!/usr/bin/perl

use LWP::Simple;

$name = "/etc/kioske.state";
if (-e $name) {
	    print "O ficheiro $name existe\n";
    } else {
            open (FILEHANDLE, ">/etc/kioske.state") || die "Não consigo criar o ficheiro Erro: $!\n";
            print FILEHANDLE "0";
            close (FILEHANDLE);
      
	}

open(FILEHANDLE, "/etc/kioske.state") || die "Não consigo abrir o ficheiro kiosk.state Erro: $!\n";

while (<FILEHANDLE>) {
	    chomp;
	    print "Vejo um $_ no ficheiro kioske.state!\n";
            $estado=0
    }

print "O estado é $estado \n";

if (get("http://www.startux.org/index.php";))  {

   $conectividade = 1;
   print "A conectividade é $conectividade \n";
 }


else  {
	$conectividade=0;
      }	


if ($estado == $conectividade)  {
	print ("Desligando, o estado é igual à conectividade\n");
	exit;
}	
 
if ($estado == 0 && $conectividade == 1)  {
  unlink ("kioske.state");	
  open (ESTADO, ">kioske.state");
  print ESTADO "1";
  close (ESTADO);
  print (" if do estado == 0 && conectividade == 1\n");

# system 'killall -w firefox-bin';

  system '/usr/local/firefox/firefox --display localhost:0.0 -fullscreen -remote openurl"(http://www.roteirosdaagua.com, new-window)" &'; 
}

if ($estado == 1 && $conectividade == 0)  {
  unlink ("kioske.state");
  open (ESTADO, ">kioske.state");
  print ESTADO "0";
  close (ESTADO);
	
#  system 'killall -w firefox-bin';
  ;

  system '/usr/local/firefox/firefox --display localhost:0.0 -fullscreen -remote openurl"(file:///home/mario/Documents/netual/kioskes/cd.html, new-window)" &';
  print ("if do estado == 1 && conectividade == 0\n");
   }
    
close (FILEHANDLE);
exit;

[Index of Archives]     [X Forum]     [Xorg]     [XFree86 Newbie]     [IETF Announce]     [Security]     [Font Config]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux Kernel]

  Powered by Linux