open browser for forecast

All other topics about postprocessing model data (GrADS and other software), about other numerical weather prediction software (including WRF-NMM and WRF-ARW discussion unrelated to UEMS/WRF EMS), and general meteorology talk go in this forum.
dominic
Posts: 336
Joined: Thu Jun 14, 2012 7:19 am

Re: open browser for forecast

Post by dominic » Tue Feb 04, 2014 8:01 am

this is error of chromium: (chromium-browser:9148): Gtk-WARNING **: cannot open display:

:?

meteoadriatic
Posts: 1584
Joined: Wed Aug 19, 2009 10:05 am

Re: open browser for forecast

Post by meteoadriatic » Tue Feb 04, 2014 8:21 am

Hello,

first problem:
dominic wrote: # / bin / tcsh
It should be

Code: Select all

#!/bin/tcsh 
Second problem:
dominic wrote: / usr / bin / chromium-browser http://www.mysite.com
It should be:

Code: Select all

/usr/bin/chromium-browser http://www.mysite.com
Change and then try. First try with firefox but make those corrections.

meteoadriatic
Posts: 1584
Joined: Wed Aug 19, 2009 10:05 am

Re: open browser for forecast

Post by meteoadriatic » Tue Feb 04, 2014 8:33 am

OK, there is a another problem because cron doesn't work inside X session and firefox do, so you must do something like this in cron:

Code: Select all

export DISPLAY=:0
Complete solution would be in cron line:

Code: Select all

10 * * * * export DISPLAY=:0 && /path/to/your/script.sh
The script.sh

Code: Select all

#!/bin/bash
/usr/bin/firefox http://google.com
exit
Tested on my Ubuntu desktop, works. It doesn't matter if you use tcsh it will also work, but you must do DISPLAY=:0 inside cron line, not in script.

And very important, pay close attention where spaces are. You put lot of spaces where they must not be.

dominic
Posts: 336
Joined: Thu Jun 14, 2012 7:19 am

Re: open browser for forecast

Post by dominic » Tue Feb 04, 2014 8:51 am

meteoadriatic wrote:Hello,

first problem:
dominic wrote: # / bin / tcsh
It should be

Code: Select all

#!/bin/tcsh 
Second problem:
dominic wrote: / usr / bin / chromium-browser http://www.mysite.com
It should be:

Code: Select all

/usr/bin/chromium-browser http://www.mysite.com
Change and then try. First try with firefox but make those corrections.

I'm sorry ivan, was google translator to put spaces, currently I have no spaces

dominic
Posts: 336
Joined: Thu Jun 14, 2012 7:19 am

Re: open browser for forecast

Post by dominic » Tue Feb 04, 2014 8:52 am

ivan but the absurd thing that annoys me is that if I go to open the terminal and write directly

cd Desktop
./myscript.sh

Firefox is opened and closed easily too!

How is it possible that crontab to make this mistake

dominic
Posts: 336
Joined: Thu Jun 14, 2012 7:19 am

Re: open browser for forecast

Post by dominic » Tue Feb 04, 2014 9:01 am

meteoadriatic wrote:OK, there is a another problem because cron doesn't work inside X session and firefox do, so you must do something like this in cron:

Code: Select all

export DISPLAY=:0
Complete solution would be in cron line:

Code: Select all

10 * * * * export DISPLAY=:0 && /path/to/your/script.sh
The script.sh

Code: Select all

#!/bin/bash
/usr/bin/firefox http://google.com
exit
Tested on my Ubuntu desktop, works. It doesn't matter if you use tcsh it will also work, but you must do DISPLAY=:0 inside cron line, not in script.

And very important, pay close attention where spaces are. You put lot of spaces where they must not be.

if I do so when the script will start opening the browser?

currently I have a script called runmodel.sh that leaves at 5:30 am

Opening the script but your browser should open after runmodel.sh ended

as you set the cron in this case?

meteoadriatic
Posts: 1584
Joined: Wed Aug 19, 2009 10:05 am

Re: open browser for forecast

Post by meteoadriatic » Tue Feb 04, 2014 1:50 pm

dominic wrote: Opening the script but your browser should open after runmodel.sh ended

as you set the cron in this case?
I guess that in that case you put this part:

Code: Select all

/usr/bin/firefox http://google.com
into runmodel.sh near the end of script (after postprocessing part of script, wherever you want to be executed).

Then edit entry in crontab that executes runmodel.sh script; put before actual command this:

Code: Select all

export DISPLAY=:0
If your current cron entry looks like

Code: Select all

10 * * * * /path/to/your/runmodel.sh
then it should be edited like this:

Code: Select all

10 * * * * export DISPLAY=:0 && /path/to/your/runmodel.sh
Should work!

dominic
Posts: 336
Joined: Thu Jun 14, 2012 7:19 am

Re: open browser for forecast

Post by dominic » Tue Feb 04, 2014 3:24 pm

Ivan you are a great, works great! thank you so much you are always a great help! :) :) :) :)


was really as complex thing, so difficult that not even those of ubuntu knew how to do :roll:

meteoadriatic
Posts: 1584
Joined: Wed Aug 19, 2009 10:05 am

Re: open browser for forecast

Post by meteoadriatic » Tue Feb 04, 2014 5:25 pm

You're welcome, I'm glad to help :)

dominic
Posts: 336
Joined: Thu Jun 14, 2012 7:19 am

Re: open browser for forecast

Post by dominic » Mon Mar 31, 2014 1:13 pm

hello ivan

I have a serious problem, basically the script works fine if the link ends with ". php or. asp etc etc)

But if the link is "complex", that draws variables via url crontab fails to run it, such as:

/ usr / bin / chromium-browser http://www.mysite.com/file.php

this works without any problems, but if I want to run:

/ usr / bin / chromium-browser http://www.mysite.com/file.php?file=newfile

crontab fails to run it ....

is there a remedy? I have the need to launch this type of url

Post Reply