Crontab for Firefox

I wrote in crontab:

*/1 * * * * export DISPLAY=:0 && /home/niklas/Desktop/firefox.sh

but then there is always the message:
No protocol specified
No protocol specified
Error: cannot open display: :0

in /var/spool/mail/username

What did I wrong?

Is what you show the ouput of

crontab -l
export DISPLAY=:0 && /home/niklas/Desktop/firefox.sh

This is a bit strange (I a still doubting what this does) . Should be:

DISPLAY=:0 /home/niklas/Desktop/firefox.sh

In who’s crontab? Only the user that is using Diaplay :0 may open a window (without further allowance).

What is the executable firefox.sh supposed to do? I can make a guess, but guessing is dangerous in a computer envirinment. One must be certain. so what about the ouput of

cat  /home/niklas/Desktop/firefox.sh

(when it is not to long).

in the firefox.sh is just a link to a website, that should be opened
like this:

firefox http://www.chip.de/

I think it is in the crontab of the user because I did it from the console, after I logged in as my user

Now I have written the content of the firefox.sh in the crontab.
Now it looks like:

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/tmp4Aly0H installed on Sat Oct 17 18:07:54 2009)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
*/1 * * * * DISPLAY=:0 firefox http://www.chip.de/ # JOB_ID_2

Still the same error.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Agreed on all points. What is your real goal? The */1 is redundant and
should just be * as it means the same thing. The use of ‘export’ and ‘&&’
is redundant and can be simplified to what was shown. Also loading
Firefox every single minute seems a little bit crazy if that is what youa
re doing, which is why I ask what you are doing. If you want something
GUI-ish loaded you also need to, as mentioned previously, allow that from
the GUI side as the user running the X session with something like
‘xhost’. The general open-it-up-for-everybody method that you should
probably not use (but which works in any case) is ‘xhost +’ but, again,
you should probably be a bit more restrictive than that if you allow
anybody on your machine besides yourself. If you are just hoping to have
Firefox always loaded that is fine but if you are trying to pull down
files or hit a page every minute there are much better ways to do that
with things like ‘wget’ and ‘curl’ which are already on your machine in
most cases.

Good luck.

hcvv wrote:
> Is what you show the ouput of
>
> Code:
> --------------------
> crontab -l
> --------------------
>
>
>
> Code:
> --------------------
> export DISPLAY=:0 && /home/niklas/Desktop/firefox.sh
> --------------------
>
> This is a bit strange (I a still doubting what this does) . Should be:
>
> Code:
> --------------------
> DISPLAY=:0 /home/niklas/Desktop/firefox.sh
> --------------------
>
>
> In who’s crontab? Only the user that is using Diaplay :0 may open a
> window (without further allowance).
>
> What is the executable firefox.sh supposed to do? I can make a guess,
> but guessing is dangerous in a computer envirinment. One must be
> certain. so what about the ouput of
>
> Code:
> --------------------
> cat /home/niklas/Desktop/firefox.sh
> --------------------
>
> (when it is not to long).
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJK2ev7AAoJEF+XTK08PnB5fckQANIL3MX+dMfXOBEhzJQNfSLD
rJawRcn6hu75P8qBckP9jnkYWeMuOMTGcvqTcT73exKP5JFijuQHREUtotIcrT0t
xFQLUo8R7XIgxPZsNTAbdOu2lbnCjld3EYZs/8hgRY66B/NgMuLwaZ5V/+vBBI9n
j6dKJwuaaUiFCFyptw+BS4UShhYde+RRx5sbBKuYa7L8FcWpfR4r5+DQb6h/jzsW
Vaun0nli/Ip8JM4mePe3NfZ7dkFc6sP/QqLozzD3UbeEOU+C46TszIEvJXCW3/5l
BZyRN5JrDzyAM3/do2MLxEmdPuERVg7DkoAf7RUC9/GI9S1vKMlP+odxXEtdey0a
Cv7n7t64QVObri06pxid8w1+VtNLOqJo/zgzd8r1OCyocnUDoum7t104Ss1ofJfi
MdtWA2v0Apv7l1ebqBjs/O0HLpEbtNC6NWvN6PglpUjJ4CTxlWq2VRJH85pj0Nv6
9F+QD8sdzu8PzK+wh2lWu3SkpS+basFcL2l6L4EF2PqM+HfoqbraMS160toNh1sR
N2/LW90wwuok2+SRSyzsZsz+mi7DpsMk1IVNvm9ejWt5ELl34f3Xqo/FZ/q3DlyR
0lxvZnimB8ZbvStcmo1p6hcejPXiBVpxnMAvBkdc1x4CzPtb31kQGb9Mt/CbileE
E9/Po5RlEorAw9tB9fKB
=5a9m
-----END PGP SIGNATURE-----

That proves that you are doing the same thing as before, but you have short cutted a few things, which is always good because it makes things clearer.

As you post is only 4 minutes after the one from ab@novell.com is suppose you did not do the* xhost + *in your running GUI. You should also think about all his remarks about starting FF every minute.

That with /1 was just an example.
Yes curl seems to be working, but I want to know how to start a GUI programm all the same.
xhost +myusername
then appears:
bad hostname: my username

ab@novell.com wrote:
> Agreed on all points. What is your real goal? The */1 is redundant and
> should just be * as it means the same thing. The use of ‘export’ and ‘&&’
> is redundant and can be simplified to what was shown. Also loading
> Firefox every single minute seems a little bit crazy if that is what youa
> re doing, which is why I ask what you are doing. If you want something

I would guess that the OP tries to reload this website in a 60sec interval.
The solution is simple: get the ‘ReloadEvery’ plugin for Ff.
Ff can be auto-loaded when you log-in of course, so the whole process is
without user interaction.

Theo

Now there is just the question how to start a grafical program in general

buugmenot wrote:
> Now there is just the question how to start a grafical program in
> general
>
>

Read this please.
http://www.catb.org/~esr/faqs/smart-questions.html

Without telling what you try to accomplish your question doesn’t
make sense, as it’s unlikely you want to hear the obvious answer.

Theo

My question:
I want to start an GUI program with help of crontab.
If I use xhost + then I can start it, but if I dont use it, I cant start it.
So is my question what to do now.
xhost +localhost I already did, too.

Why don’t you just cut and paste what you are doing instead NOT of typing in your post what you see. This may sound harsh, but I do not believe that you type ‘myusername’ in the command and that you then get ‘my username’ (see the white space!) in the resulting message.
As an example on how, at least I, but I suggest more people here, think of halfway trusted information I show you here what happens on my system when I use xhost:

henk@boven:~> xhost +henk
henk being added to access control list
henk@boven:~> 

I can also assure you that this works also with any ‘name’, regardless being it is a real username or not. The result is that I am not a great believer of what you tell us.

I also note that ab@novell.com told you that the ultimate test is to switch xhost access control completely off:

xhost +

for a test. The security impact is ver minor when you do switch it on after the test:

xhost -

This will free you from any interpretation errors and typos in the name after the +. Why didn’t you do that (or did you, but did you not report)?

My question:
I want to start an GUI program with help of crontab.
If I use xhost + then I can start it, but if I dont use it, I cant start it.
So is my question what to do now.
xhost +localhost I already did, too.

There I wrote, that I tested xhost + and that I than could start GUI programs.
Now you can see, what I typed:

niklas@linux-wfyp:~> xhost +niklas
xhost:  bad hostname "niklas"

OK, seeing what you are doing makes it much better.

When I do

henk@boven:~> xhost +niklas
xhost:  bad hostname "niklas"

I get the same. So what about my earlier statements? I did them again and then asked xhost what it has:

henk@boven:~> xhost +aap
aap being added to access control list
henk@boven:~> xhost +henk
henk being added to access control list
henk@boven:~> xhost
access control enabled, only authorized clients can connect
INET:henk.xs4all.nl
INET:aap.xs4all.nl
henk@boven:~>

What happened here is that *henk *and *aap *are both existing hosts in my domain (xs4all.nl), which I was not aware of :’(.

I played around with it a bit, reading the man page and trying to start *xclock *from the logical console (via Ctrl-Alt-F1 and back via Ctrl-Alt-F7). The following worked:

henk@boven:~> xhost +local:
non-network local connections being added to access control list
henk@boven:~> xhost
access control enabled, only authorized clients can connect
LOCAL:
henk@boven:~>  

Explanation: nowadays almost all internel ‘network’ connections are not done via *localhost, *but via UNIX domain sockets.
Using the family local: also does not allow remote users and thus is rather secure.

You can put the xhost +local: at the end of your .profile to let it be executed at every login.

Thanks!
Now it is working.

You are welcome!

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

That’s all. just run xhost + in the GUI each time you login.

Good luck.

buugmenot wrote:
> My question:
> I want to start an GUI program with help of crontab.
> If I use xhost + then I can start it, but if I dont use it, I cant
> start it.
> So is my question what to do now.
> xhost +localhost I already did, too.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJK28qhAAoJEF+XTK08PnB5ZBIQAL1+vtL0fwphmCHqM2i4tviO
dL4Z6q5KgWK2aBYBv4r52Kld01SYaHyo0qu3TWGr+XQGPTkWIzmHOZ+E1QWK8eOF
DLJVF8XwQXx3NY5mJIOG4w0QZrkb5Zfu859iPArHJQ5knXbfqLAdhjc6GtnxXjN7
bH0M+kitU/EABgS1rLPNN+AQXMyn8JFxGP0zjUC1tVrZZFn53IgWRsbwav1r/hDf
m64koP4vZ2zym688rermVt3xOPaHV3CtadFAG4231xAXq81dVpVu5L8ltJhdPKgu
rmvT+VG/exEocZOmcBoWsFcfdD7XoI2+fhkunRLEkCXu25vKKtqQAYVkz8o2iMxS
FFpxMYzqC5TnmNbnq31l7CK/BkNLgm/7YdZGvfa0kPTXTOIxlPwiR4EucCHQsOWI
WTrVNYxJboA6tcc7czlzTJdr80Z1tXvMwOJrPOnf6k7ZO6NGDeADKKSdvPMPsmSm
72nm5W56r7n6BGstibXJYUkpEmVBOe74QMT4OVX1mIvvVqVCMbOGghNMrDLkr/9P
kGprMzPv4GsvuI3cM0fbEIHkSlU+0fAF9DgzPx1SwgJQDePgblllOcmYAMIGwang
mTfn7Mmrz3KeWaby7rbtANRaoH0hJTEGFy0VKiFfWWZk7lqt3na62PhR9WLjDPrc
mtaBRhX08rkwUcodzVT7
=6Zld
-----END PGP SIGNATURE-----