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;

Reply via email to