Operating System - HP-UX
1753774 Members
6572 Online
108799 Solutions
New Discussion юеВ

Re: How to set DISPLAY variable thru cron when no tty

 
Frank de Vries
Respected Contributor

Re: How to set DISPLAY variable thru cron when no tty

Victor

VNC is a well known product.
unfort it is blacklisted by our security dept.
So am I not authorised to used it.

Still I could propose it to them,
since I need a workaround.
Question:
Do you stop and start the vnc thru cron ?
and/or do you use a bootscript ?

Otherwise it won't be worth my while,
as my startup script with DISPLAY concept works , except thru cron

u c :)


Look before you leap
Andrew Merritt_2
Honored Contributor

Re: How to set DISPLAY variable thru cron when no tty

Frank,
I think you're comparing apples with oranges.

Yes, a java connection can be similar to a telnet connection, but we don't have either of these when cron runs. The issue is that when cron runs the script, there is no incoming connection at all, so no way to determine the DISPLAY value.

The root profile that you refer to is run when a connection has already been made; it's part of the login process. This is not the same as running a script at a fixed time on the server, with no incoming connection, which is what is happening with cron.

The determination of what value DISPLAY has needs to be done when a connection comes in, if I understand the situation, and that is not what is happening when you restart the server with cron.

What is the reason for the restart with cron, anyway?

Andrew
Frank de Vries
Respected Contributor

Re: How to set DISPLAY variable thru cron when no tty

Andrew

The discussion is getting pointless:
It seems difficult to get us aligned on
the same wavelength.

I feel that you completely misunderstand me,
and it appears I am not capable of making myself clear. As response I would just
repeat what I have said earlier, but it
is not getting through;

Probavly why I earn six$$$$$$ with unix/oracle and not as an english language teacher or communication consultant.

I will allocate points for your trouble
and thanks for all the replies !
Look before you leap
Frank de Vries
Respected Contributor

Re: How to set DISPLAY variable thru cron when no tty

ok
Look before you leap
Andrew Merritt_2
Honored Contributor

Re: How to set DISPLAY variable thru cron when no tty

Frank,
Sorry you feel we're not getting anywhere with this. The questions I was asking were a genuine attempt to understand the problem, and explain why it didn't seem possible to do what you wanted with cron, based on the information available.

I'd suggest you re-read my responses, and particularly Bill's, and try to understand why it is not at all clear what value you can assign to DISPLAY if you run this script from 'cron' rather than when a client connects. It's possible there's an assumption you're making about the set-up that we're not party to that would make a difference.

Andrew
(If you're only earning $6, you might want to look around :-) )
Frank de Vries
Respected Contributor

Re: How to set DISPLAY variable thru cron when no tty

I appreciate your genuinity :)

Just feel that we are off a tangent,
all I wanted was to know possible
workaround.

The setting of the DISPLAY in a script
that stops and starts WebSphere in de
weekend fails. IT ONLY FAILS IN THE
CRONJOB not otherwise !!!!!!!!!!

Thus this line fails when run in the
script as a cronjob:
DISPLAY=`who -mR | sed "s=.*(==;s=[:)].*=="`:0.0

And I agree with you that Bill provided
the best answer sofar. There is no tty
(Matrix: there is no spoon)

However, I have not a problem running
the stuff outside cron nor during a
reboot of the server. Thus I repeat
only when run through cron.

And Java is quite capable of responding to
software rendered connections without prior
knowledge and quite dynamically reply with
stuff using unix generic X11.

So , I don't realy have a problem.

Thanks for looking after me so much,
love and peace :)



Look before you leap
Victor BERRIDGE
Honored Contributor

Re: How to set DISPLAY variable thru cron when no tty

Hi again Frank,
You could give a try with xvfb (which can be configured a similar way and may be accepted your security staff..)
To answer your question:
No not used by cron nor startup because they are configured in MCSG packages (4 node cluster) and we use controlm as scheduler...
but what I can say is that stop/start are called by batch script, so it should work in your startup/stop scripts


All the best
Victor
Andrew Merritt_2
Honored Contributor

Re: How to set DISPLAY variable thru cron when no tty

Hi Frank,
I don't want to give up on this, but I'm not sure how I can convince you that you've already had the answer. I'll have what is probably one last go.

I fully understand that the problem only happens with cron. What you're not seeing is that it is exactly because running from cron is different, since the information available at the time is different.

We're not going off at a tangent, this is the heart of the matter.

When the script is run due to an incoming connection, information about that connection can be used to determine what value to set DISPLAY to, to get the window to go to the right place.

When you run the script from cron, there is NO incoming connection. In that circumstance, where do you want the window to appear? There just isn't any information that the script can use to decide this. Perhaps you don't fully realise what 'cron' is doing. It does not create a login session, it just runs a script on the server, with the permissions of the specified user, but with no associated terminal.

You mention running the script during a reboot of a server, but from other comments you have made I think you are referring to the 'profile' file for the root user, which does not get executed until someone logs in, so at that point there is a value for 'tty'. If you mean something different, please explain how it gets a value for 'tty'.

You say that java is capable of responding to 'software rendered connections', but I repeat, there is NO CONNNECTION when cron runs the script.

I'm afraid I'm failing to get across something fundamental about how cron is working, and why this explains what you are seeing, and why it just doesn't seem possible to do what you want, without making an assumption about where you want the display window to pop up when cron creates it.

All I can suggest is for you to try to explain where it is you want the server to connect to when cron runs the script. Bear in mind that there is no client running at this time requesting a connection (which is the case in all the other examples you give; normally the script is being run in response to a client doing something).

Andrew
Frank de Vries
Respected Contributor

Re: How to set DISPLAY variable thru cron when no tty

Hi again Andrew

I appreciate our reply.

Do you consider that cron is
used to start a application,
albeit in background.

Tes, we do login !!
To the WebSphere server (WS).
(provided it started okay)

Once we are logged in (WS) we have a whole lot of functionality at the application side some of which uses the X11 service and as you know the DISPLAY is vital there.
Well the rest you know.

What bothers me is that even thought I am aware that cron has no tty, still it could pass on the variable in the background job 'as is' instead to foobar it.

I appreciate it is different with cron
because the information available is
different.

I will have to find another solution,
coming from a complete different angle.

Still I feel it is always worthwhile to
test conventional ideas here at the forum.
It is not the first nor the last time some
vested mythical believe about what unix can
and cannot do is shattered to pieces.

Ok not this time it seems:)
Thanks Andrew for spending your time
on this anyway.







Look before you leap
Andrew Merritt_2
Honored Contributor

Re: How to set DISPLAY variable thru cron when no tty

>What bothers me is that even thought I am
> aware that cron has no tty, still it could
> pass on the variable in the background job
> 'as is' instead to foobar it.


Yes, but... cron doesn't have any value to pass on in the DISPLAY variable. It is starting up in isolation. What value do you think that DISPLAY has, that can be passed on 'as is'?

cron can set an arbitrary value for DISPLAY and pass it on, but we return to the point which is that as far as I can see it has no way of determining what value to set it to.

Where do you think the X11 window will be displayed when cron runs the script?

Andrew