Automatic DISPLAY setting in UNIX - script

  • abhinav_8182
  • Beginner
  • Beginner
  • User avatar
  • Posts: 41

Post 3+ Months Ago

Hi All

THis is the code that i have written for Automatic DISPLAY setting in UNIX


XSERVER=$(who am i -R| awk '{print $NF}' | tr -d ')''(' )
XSERVER=${XSERVER%%:*}

if [[ -z ${XSERVER} || ${XSERVER} == $(hostname) || ${XSERVER} == "unix" || ]]; then

DISPLAY="${XSERVER}:0.0" # Display on local host
else

XSERVER=$(who am i | awk '{print $NF}' | tr -d ')''(' )
XSERVER=${XSERVER%%:*}
DISPLAY=${XSERVER}:0.0 # Display on remote host
fi
#fi


Could anyone please rectify this code for automatic DISPLAY setting in unix

This one automatically sets the display of my machine when i do a telnet to some machine but not on itself

One more issue is that ...On some systems the command "who am i " does not output the machine name (as on my system) but "who am i -R" does. Wheras on other systems like SunOS ....it's the other way round. So I had to use the command twice in my code , once with n then without the option "-R"


please help

Best Regards

Abhinav
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • abhinav_8182
  • Beginner
  • Beginner
  • User avatar
  • Posts: 41

Post 3+ Months Ago

O.k ....finally got thru ....It was quite simple

Here's the working code

SYS=$(uname)
case $SYS in
"HP-UX")

XSERVER=$(who am i -R| awk '{print $NF}' | tr -d ')''(' )
;;

*)
XSERVER=$(who am i | awk '{print $NF}' | tr -d ')''(' )

;;

esac

XSERVER=${XSERVER%%:*}
DISPLAY=${XSERVER}:0.0 # Display on remote hst


"who am i " does not give the desired o/p on any HP-UX systems

Donno if there are some others too ........

But definately works on OSF n SunSolaris systems



Regards

Abhinav

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 61 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.