Serial and parallel port mapping
By ThinGuy on Mar 01, 2006
This is one of my favorite scripts. It automatically detects any serial or parallel ports that you may have connected to your Sun Ray and creates a symlink(s) in your home directory for easy mapping. These may be USB to Serial/Parallel adaptors, or in the case of the Sun Ray 170, the two built in serial ports. Upon hot desking utaction invokes the script checks to see if the new Sun Ray has these ports then updates the symlinked entries.
Why is this important?
First of all these type of devices are tied to the physical Sun Ray device, it requires a fairly complex path to be entered into certain programs that you would want use these ports. Wouldn't you agree that $HOME/utports/com1 is a lot easier to enter than /tmp/SUNWut/units/IEEE802.080020cf428a/dev/term/Digi-67a?
Second, when you hot desk you want to make sure that these devices pointing to the correct device since the path will have changed due the MAC address of the new DTU or even a different type of port adaptor.
This script will work with both normal sessions and CAM sessions. It makes it very easy to do things like serial port mapping using programs like rdesktop or Citrix since you only have to make one global setting for all users of something like $HOME/utports/com1 vs trying to figure out the path to the device for every single Sun Ray that may or may not have an adaptor. The script also keeps track of physical to symlinked port names in $HOME/portmap.txt and if no devices are found, states so in this file as well.
Like other scripts that I do for Sun Ray Server this will be done in two parts. The first script sets up utaction to call the second script which does all the real work.
You can download the sample scripts here
The first script can be called as a default CAM application, or could be called as a numbered startup file in /usr/dt/config/Xsession.d. For CAM, I prefer to have it called by my main CAM application.
# UTACTIONS for COM and LPT port mapping
/opt/SUNWut/lib/utaction -i -c $BASEDIR/utports &
The second file should be stored in /opt/UTPorts and can be called utports. Wherever you store it and whatever you call it, just make sure it's reflected in the first script.
# utports - Written by Craig Bender, Sun Ray Engineering
# --Begin Script--
# Make sure we are on a Sun Ray
if [ ! "$UTDEVROOT" ];then
echo "Not on a Sun Ray. Exiting.\\n"
# Check to See if a ports directory exists. If it does, remove all com\* and lp\* entries,
# otherwise create the directory. Removal is done for HotDesking.
# Check to see what Com ports exist
if [ -d $UTDEVROOT/dev/term/ ];then
# Check to see what printer ports exist
if [ -d $UTDEVROOT/dev/printers/ ];then
if [ ! "$COMPORTS" ] && [ ! "$LPPORTS" ];then
echo "No serial or parallel ports found connected to this Sun Ray" > $HOME/porterr.txt
# Set the port directory to store symbolic links
if [ -d $HOME/utports ]; then
rm $PORTDIR/com\* > /dev/null 2>&1
rm $PORTDIR/lp\* > /dev/null 2>&1
# Delete porterr.txt if we have gotten this far
# Create/Refresh $HOME/portmap.txt
if [ -f $HOME/portmap.txt ];then
# Enumerate serial ports as com1-comx
if [ ! "$COMPORTS" ];then
echo "No serial ports found connect to this Sun Ray" >> $HOME/portmap.txt
for comportname in $COMPORTS; do
ln -s $UTDEVROOT/dev/term/$comportname $PORTDIR/com$comport
echo "$UTDEVROOT/dev/term/$comportname = com$comport" >> $HOME/portmap.txt
comport=`expr $comport + 1`
# Enumerate parallel ports as lp1-lpx
if [ ! "$LPPORTS" ];then
echo "No parallel ports found connect to this Sun Ray" >> $HOME/portmap.txt
for lpportname in $LPPORTS; do
ln -s $UTDEVROOT/dev/printers/$lpportname $PORTDIR/lp$lpport
echo "$UTDEVROOT/dev/printers/$lpportname = lp$lpport" >> $HOME/portmap.txt
lpport=`expr $lpport + 1`
# close out the if statement for the Sun Ray check
# --End script--
Let me know how this works for you. Have fun!