Operating System - HP-UX
1835527 Members
3226 Online
110078 Solutions
New Discussion

Control xterm timeout connecting to remote display?

 
Barry O Flanagan
Respected Contributor

Control xterm timeout connecting to remote display?

Is there any way of controlling the time it takes for an xterm/hpterm to timeout, or stop trying to open on a remote machine if it can't contact an X server on the remote machine?

Timeout seems to be 10 seconds :

$ date ; xterm ; date
Wed Jul 25 09:40:03 BST 2001
Error: Can't open display: 10.1.1.1:0.0
Error: Couldn't find per display information
Wed Jul 25 09:40:13 BST 2001

Note: when I try this on other O/S the timeout seems to be quicker, like more in the region of 5 seconds.

Any ideas?
TIA,
Barry
3 REPLIES 3
Alex Glennie
Honored Contributor

Re: Control xterm timeout connecting to remote display?

here's some timeouts that may help but I'm dubious if they will help .... see man dtlogin & /usr/dt/config/Xconfig .... is nfs involved ->default = 5 secs , normally standard openTimeout = 30 secs ..... I guess you could try dropping this value ? nb you will need to restart the Xserver for the changes to take effect.

good luck
Bill McNAMARA_1
Honored Contributor

Re: Control xterm timeout connecting to remote display?

Hi Barry, I just found this script function that'll check if a connection is X capable.
I'll leave you to figure it out.. but it uses xhost to find out if it's a display or not.
I couldn't find your original question so I'm posting here.


function Xcapable
{
typeset R disp
# we want to know if we are running on a X capable system or not
# we try to run the 'xhost" command which fails if not capable
xhost >/dev/null 2>&1
R=$?
if [ $R != 0 ]; then
# check if DISPLAY is set to an empty string by piping error
# output to grep
xhost 2>&1 | /bin/grep "xhost: unable to open display \\\"\\\"" > /dev/null
R=$?
if [ $R = 0 ]; then
# if grep succeeded, then DISPLAY is empty
# ... then try to set it to a suitable value.
disp=$(GetDisplayName);
ttlTrace COM_E_LL_INFOFLOW1 "$0 : DISPLAY was empty. Now set to $disp"
export DISPLAY="$disp"
# check again xhost with the new DISPLAY value
xhost >/dev/null 2>&1
R=$?
fi
fi

ttlTrace COM_E_LL_INFOFLOW1 "$0 returns $R"
# get the return value from the "xhosts" command (0 if successful)
return $R
}



Another one you were interested in was getting the display name to set to:

function GetDisplayName
{
typeset dis displayName

# the command "/bin/who am i -R" returns something like
# "subbin pty/ttys2 Sep 22 10:53 (hptnoops.grenoble.hp.com)"#
# where the () enclosed part at the end is the name of the station
# supporting the display.
# awk filter removes parentheses.
dis=`/bin/who am i -R | /usr/bin/awk '{gsub("[()]","",$6); printf "%s",$6}'`
ttlTrace COM_E_LL_INFOFLOW2 "$0 : display value found = $dis"
case "$dis" in
*:[0-9].[0-9]) displayName=${dis};;
*:[0-9]) displayName=${dis} ;;
*) displayName=${dis}:0 ;;
esac
ttlTrace COM_E_LL_INFOFLOW1 "$0 returns $displayName"
#
# ----------------------------------
echo $displayName # This is the "returned value"
# ----------------------------------
return 0
}

Later,
Bill
It works for me (tm)
Barry O Flanagan
Respected Contributor

Re: Control xterm timeout connecting to remote display?

Alex/Bill,

As always, thanks for the swift replies...

Not really concerned with whether I can check if the display is X or not anymore, cos I can do that a couple of ways like your nice xhost method (eg: xset -q, xrdb -symbols etc... will fail if not Xwindow). Its more the time it takes for it to decide if its X or not.

So lets say I usually run an X emulator on my PC and I try to kick off an xterm on my hp box with my DISPLAY set to my PC IP. That all works fine and the xterm is displayed instantly on the PC. However, if I don't run the X emulator and then try to kick off the xterm with my DISPLAY set to my PC IP then the xterm will try to connect to the X server on my PC but will fail after 10 secs with a :

Error: Can't open display: 50.120.4.167:0.0
Error: Couldn't find per display information

But I want it to fail instantly!