- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to set DISPLAY variable thru cron when no ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2005 02:36 AM
тАО11-24-2005 02:36 AM
Re: How to set DISPLAY variable thru cron when no tty
If you want to use the same script, then perhaps you test the result of 'tty' to see if you have a tty value; if not use the value you want to use for cron, otherwise continue as you already do.
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2005 04:04 AM
тАО11-24-2005 04:04 AM
Re: How to set DISPLAY variable thru cron when no tty
So as suggested, you must hardcode the DISPLAY variable in your script. HOWEVER: the DISPLAY computer (a PC in this case, which is running Reflection/X) must *never* be logout, shutdown or rebooted. The display screen (which is Windows plus Reflection/X) must always be ready to display something from cron.
Now here's the question: who is going to be sitting in front of the PC when this cron job runs? Does this cronjob require someone to answer questions? Requiring a display device, whether it is a simple ASCII terminal or a graphics program in order to startup seems like a very poor design.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2005 02:44 PM
тАО11-24-2005 02:44 PM
Re: How to set DISPLAY variable thru cron when no tty
if [ "$TERM" -a "$DISPLAY" ]; then
# Set up the terminal:
if [ "$TERM" = "" ]
then
eval ` tset -s -Q -m ':?dtterm' `
else
eval ` tset -s -Q `
fi
stty erase \^H intr \^c kill \^u eof \^d susp \^z echoe echok
stty hupcl ixon ixoff
tabs
set -o vi
prompt="[\!] # "
export PS1=`/usr/ucb/whoami`@:`uname -n`:'$PWD'${prompt}
fi
you could get even fancier by added
if [ ! "$VUE" ]; then
...
fi
Also for interest sake you can get the DISPLAY using the following 1 line as opposed to the 2 lines given above.
DISPLAY=`who -mR | sed "s=.*(==;s=[:)].*=="`:0.0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2005 07:19 PM
тАО11-27-2005 07:19 PM
Re: How to set DISPLAY variable thru cron when no tty
Andrew
You anwser my question with more questions.
Interesting :)
I clarify:
I clearly mentioned it concerned a
startup script for WebSphere.
So any client (pc) that contacts the server
can only receive a session back if
the DISPLAY variable can be set dynamically.
A static DISPLAY just won't cut it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2005 07:56 PM
тАО11-27-2005 07:56 PM
Re: How to set DISPLAY variable thru cron when no tty
Ron , you missed the point about my tty
command , that was for your benefit, I put
it there purposfully.
Still thanks for you one-liner, I will
add that to my collection :)
Bill:
Your answer seems the most mature.
It is a graphics env in java, trying to
send back a pdf on the fly.
Probably you are right it is poor design,
but it wasn' t mine.
But Java env must be started with
DISPLAY set. Problem in weekend we
stop and start with cron.
Will have to find another way to stop/start,
maybe using rlogin or remsh or telnet localy,
to get this tty anyway.
Thankx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2005 07:59 PM
тАО11-27-2005 07:59 PM
Re: How to set DISPLAY variable thru cron when no tty
>So any client (pc) that contacts the server
>can only receive a session back if
>the DISPLAY variable can be set dynamically.
>A static DISPLAY just won't cut it.
Right, but what you're doing is restarting the server using cron, at which point you no longer have an active connection, so how do you know what you want to set the DISPLAY variable to? Are you trying to reconnect to a client that's talking to the server, or just restart a client that's run on the server machine and displays on a remote one? Is the remote machine likely to always be up?
Or are you saying you want to kill the server, which will kill the active connection (can there only be one, or many?), and re-open a connection to a client when you restart the server? In that case, when the connection is originally made, you could save the value of DISPLAY to a file, and read it when you restart the server (of course, the client might have gone away in the interim).
I'm sorry, but what you're trying to do with cron is not well described, or perhaps you don't fully understand what cron is and isn't capable of.
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2005 08:16 PM
тАО11-27-2005 08:16 PM
Re: How to set DISPLAY variable thru cron when no tty
Indeed I underestimated cron limitations,
you are right there. Is was aware of that,
but I was hoping for a workaround, trick,
whatever, cos one never knows everything.
For me it is not necessary to know
beforehand the client who could come
knocking on the web server's door.
As long the DISPLAY variable is dynamically
set.
Compare this to your plain old X11telnet login: If you set (using the nice one liner from Ron) DISPLAY=`who -mR | sed "s=.*(==;s=[:)].*=="`:0.0
then you could login from any client,
and your unix server wouldn't know
which one beforehand, but your display
would be correctly set.
Java works no different, only login is
replaced by software rendered connections
that's all. But still it needs the DISPLAY.
Got the feeling I did more explaining on
this questions then I got ideas from it :) :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2005 08:24 PM
тАО11-27-2005 08:24 PM
Re: How to set DISPLAY variable thru cron when no tty
In the case of the telnet login, there is something that indicates where the connection is coming from, and you can set the DISPLAY variable based on that.
But in the case where you are running the script in cron, there is no incoming connection, so I really don't see how you expect to determine what you want DISPLAY to be. That's what I'm trying to understand.
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2005 09:00 PM
тАО11-27-2005 09:00 PM
Re: How to set DISPLAY variable thru cron when no tty
My previous post would have solved your problem...
We have a similar situation, and we need a display to capture pdfs...
We use vnc :
http://www.realvnc.com/what.html
e.g.
(define a vnc server as display server)
/home/appoper:vncserver :4
New 'saler:4 ()' desktop is saler:4
Starting applications specified in /home/appoper/.vnc/xstartup
Log file is /home/appoper/.vnc/saler:4.log
/home/appoper:export DISPLAY=localhost:4.0
/home/appoper:xhost +
access control disabled, clients can connect from any host
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2005 09:19 PM
тАО11-27-2005 09:19 PM
Re: How to set DISPLAY variable thru cron when no tty
I think you understand it, but now just
translate what you know to the java virtual machine which also can act as login daemons (only sofware rendered) as opposed to inetd deamon that listens to your login and spawns a getty and .profile in unix when connecting.
Imagine this concept but transpose it
to java's logics and you'll see
it is no different in essence.
As to the fact that is started by cron,
can maybe be compared when you
boot a unixserver there is also no user
connecting nor involved. Still it is quite legal to put in the root profile (other
other user's profile) the DISPLAY command dynamically (see Ron's oneliner), and then
connecting from a pc with e.g. reflectionX ,
it will attach a tty and with that with
who -u you can obtain the hostname of
the client. so DISPLAY can be programmed
on this basis with variables, except
thru cron unfort.
Hope u c :) :)