XDOM API in UniVerse

[Origin]: https://stackoverflow.com/questions/1727776/xdom-api-in-universe

I am building an xml parser and constructor using the XDOM functions in UniVerse 10.1.0. Things are going fine until I get to use the XDOMAddChild function. I can add single elements fine using the handles but I get an error when adding a tree. The manuals indicate adding a tree is fine.

XDOMAddChild function

Syntax

XDOMAddChild(xmlHandle, xpathString, nsMap, nodeHandle, dupFlag)

Description

The XDOMAddChild function finds the xpathString in the context xmlHandle in the DOM structure and inserts a node nodeHandle as the last child of the found node. If the inserted node type is XDOM.ATTR.NODE, this node is inserted as an attribute.

Parameters

The following table describes each parameter of the syntax. Parameter Description

xmlHandle The handle to the context. [IN] xpathString Relative or absolute Xpath string. [IN] nsMap The map of namespaces which resolve the prefixes in the xpath string. Format is “xmlns=default_url xmlns:prefix1=prefix1_url xmlns:prefix2=prefix2_url”

For example: “xmlns=http://myproject.mycompany.com xmlns:a_prefix=a.mycompany.com” [IN]

nodeHandle Handle to a DOM subtree. If nodeHandle points to a DOM document, all of its children are inserted, in the same order. [IN]

dupFlag XDOM.DUP: Clones nodeHandle, and inserts the duplicate node. XDOM.NODUP: Inserts the original node. The subtree is also removed from its original location. [IN]

I accept the XDOM faults and flaws (particularly with building namespace prefixes) and an willing to work with them, But this one may be a show stopper with the current logic I am using. This is some test code:

$INCLUDE UNIVERSE.INCLUDE XML.H                                           
DATA.REQ = '<logonResponse></logonResponse>'
TEST.CHILD = '<logon>HELP</logon>'
NSMAP = ''
*
ERR$ = XDOMOpen(DATA.REQ, XML.FROM.STRING, DOM$H)                
  Status = XMLGetError(ERR$,errMsg)
  PRINT ERR$:',':errMsg 
ERR$ = XDOMOpen(TEST.CHILD, XML.FROM.STRING, CHILD$H)                
  Status = XMLGetError(ERR$,errMsg)
  PRINT ERR$:',':errMsg
ERR$ = XDOMLocate(DOM$H,'//logonResponse',NSMAP,NOD$H)                                   
  Status = XMLGetError(ERR$,errMsg)
  PRINT ERR$:',':errMsg
ERR$ = XDOMWrite(NOD$H,JUNK,XML.TO.STRING)
PRINT JUNK
ERR$ = XDOMWrite(CHILD$H,JUNK,XML.TO.STRING)
PRINT JUNK
ERR$ = XDOMAddChild(DOM$H, '',NSMAP,CHILD$H, XDOM.NODUP)
IF ERR$ = XML.SUCCESS THEN PRINT 'SUCCESS'
IF ERR$ = XML.ERROR THEN PRINT 'ERROR'
IF ERR$ = XML.INVALID.HANDLE THEN PRINT 'INVALID'
  Status = XMLGetError(ERR$,errMsg)
  PRINT ERR$:',':errMsg
END

I get this back….

1004,A DOM exception occured in function XDOMAddChild, DOM Exception code: 4

If I use XDOMCreateNode to create the TEST.CHILD element, the XDOMAddChild works fine. The only difference I can prove ids that the inserted node hanlde is different between teh 2 examples. The one that works the nodehandle is XDOM.ELEMENT.NODE (Type 1) and the one that fails in XDOM.DOC.NODE (Type 9).

Not sure where to go from here. Any code snippets, links, pointers; greatly appreciated

shareedit

An XML Document is a different kind of beast than an XML Element. A document must contain one, and only one element: the document root, which contains the other elements. It’s can’t directly contain attribute or text nodes. It can contain DTDs, processing instructions, and a declaration, all of which are forbidden for an element to contain. An element can contain nodes; either text, attributes or other elements. An element can’t contain a document.

You answered your own question here:

If I use XDOMCreateNode to create the TEST.CHILD element, the XDOMAddChild works fine. The only difference I can prove ids that the inserted node hanlde is different between teh 2 examples. The one that works the nodehandle is XDOM.ELEMENT.NODE (Type 1) and the one that fails in XDOM.DOC.NODE (Type 9).

Don’t use XDOMOpen, use XDOMCreateNode OR XDOMLocate. You need an element, attribute or text node. A document won’t work.

shareedit

I actually made a small blog post regarding U2 XDom errors just before Christmas.

I assume UniVerse and UniData use the same XDOM parsers, so you can should be able to work out what that error refers to from the Xalan documentation.

In this case, Error 4 refers to ‘WRONG_DOCUMENT_ERR’

Hope it helps somewhat…

shareedit

Thanks,

The crux of my problem was that I was confused about the “Document” type as opposed to the “element” type.

eg: You can only use XDOMLocate on the “Document” Type Node. I was trying to use this function on a “element” Type node. The code below will no work because the 2nd Locate is performed on an “element” Type node.

  XMLDOC = <rootNode><nodeItem><data>aaa</data></nodeItem><nodeItem><data>bbb</data></nodeItem></rootNode>
  ERR$ = XDOMLocate(DOM$H,'//rootNode','',NOD$H)
  ERR$ = XDOMLocateNode(NOD$H,XDOM.CHILD,XDOM.LAST.CHILD,XDOM.ELEMENT.NODE,SUBNOD$H)
  ERR$ = XDOMLocate(SUBNOD$H,'//nodeItem/data','',DATA$H)
  ERR$ = XDOMLocateNode(DATA$H, XDOM.CHILD, XDOM.FIRST.CHILD, XDOM.TEXT.NODE, TEXT.NODE)
  ERR$ = XDOMGetNodeValue(TEXT.NODE, DATA$VALUE)

DATA$VALUE will not be extracted to “bbb”. This is how to do it..

  ERR$ = XDOMLocate(DOM$H,'//rootNode/nodeItem[2]/data','',DATA$H)
  ERR$ = XDOMLocateNode(DATA$H, XDOM.CHILD, XDOM.FIRST.CHILD, XDOM.TEXT.NODE, TEXT.NODE)
  ERR$ = XDOMGetNodeValue(TEXT.NODE, DATA$VALUE)
All nodes are not created equal.
shareedit
Advertisements

K2 Memo Line Break

[Origin] http://community.k2.com/t5/K2-blackpearl/Memo-Line-Break/td-p/66586/page/3

Regarding adding a line break to a memo field. I solved a similar problem using just expressions and it is still working under 4.6.11. I used the operators/text/url_decode function. This is intended for decoding url strings (obviously), but seems to work for this situation as well. Example:

2015-12-10 CR expression.png

SmartObjectServiceFunctions – Authentication Failed: The target principal name is incorrect

[Origin] http://community.k2.com/t5/K2-blackpearl/SmartObjectServiceFunctions-Authentication-Failed-The-target/ta-p/87586

Symptoms 

SmartObjectServiceFunctions – Authentication Failed: The target principal name is incorrect

Diagnoses
When you receive an error when trying to Create CRM Entity Item within K2 Studio.

As a result you are unable to connect to the CRM Server despite being able to use the Smart Object Tester to create records using the relevant Smart Object.

Resolution

You can resolve this issue by refreshing the ‘SmartobjectServicefuction’ service instance and service object. After this you should be able to drag in the event to any activity within studio.

Note: use the server tool ‘SmartObjects Service Tester’ to refresh it.

unibasic select woes

[Origin]: http://u2-universe-unidata.1073795.n5.nabble.com/unibasic-select-woes-td15195i20.html

RE: unibasic select woes

Morelli, David W.
6 posts
Thank you.  The “‘word’…” format is the answer to a question that had
me banging my head yesterday.

David Morelli, UIS/Datatel Team

—–Original Message—–
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Andre Meij
Sent: Wednesday, May 30, 2007 5:10 PM
To: [hidden email]
Subject: RE: [U2] unibasic select woes

Greg,

Actually the following in saver:

SELECT HRPER WITH EVAL “OCONV(HRP.LAST.NAME,’MCU’)” LIKE “‘SC’…”

(note the extra ‘ around the text) there are a few alphanumeric
characters that are interpreted by SELECT and it will show you weird
results when you are not expecting that.

Regards,

Andre

—–Original Message—–
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Greg Schraiber
Sent: maandag 30 april 2007 11:12
To: [hidden email]; [hidden email]
Subject: RE: [U2] unibasic select woes

Dave, Wyatt  & Karen,

Thank you so much for the tips!
Works like a charm!

Thanks again,
Greg

At 12:45 PM 5/30/2007, Dave Davis wrote:

>In ECLTYPE u
>
>SELECT HRPER WITH EVAL “OCONV(HRP.LAST.NAME,’MCU’)” LIKE “SC…”
>
>If you are currently in ECLTYPE p, you can put the word “SELECT” in
>lowercase to evaluate using the “u” parser.
>
>—–Original Message—–
>From: [hidden email]
>[mailto:[hidden email]] On Behalf Of Greg Schraiber
>Sent: Wednesday, May 30, 2007 1:28 PM
>To: [hidden email]
>Subject: [U2] unibasic select woes
>
>How does one select alpha-numeric data from a unidata datafile using
>SELECT when the case of the text is not known?
>
>I have tried things like:
>SELECT HRPER WITH UPCASE(HRP.LAST.NAME) LIKE ‘SC…’
>but all I get is a syntax error.
>
>Can someone tell me which function(s) can be used to facilitate this
>type of search?
>
>Any help is greatly appreciated!
>
>Thank you,
>Greg

U2 XML Example

[Origin]: http://www.mvdeveloper.com/kb/docs/kb10.pdf

[Reference]: https://u2devzone.rocketsoftware.com/accelerate/articles/u2-xml/u2-xml

U2 XML Example

 

Below illustrates some U2 XDOM functions for working with an XML document.

The XML document should be placed in file &XML& with the ID of “SAMPLE.XML”

to work with this code.

This example was created in response to the follow message posted on the u2-users group

on 8th October 2008 which can be found at http://listserver.u2ug.org/.

 

XML from the message above cleaned up

 

Save this as “SAMPLE.XML” in file &XML&

Hello all,

I have to be able to parse out an XML file being sent by an

laboratory instrument.

Below is a sample file… I need to be able to get to the ID

attribute in SA, as well as the Key in AR, and AR’s data.

I need to do this in BASIC, and pass the parsed data to another

routine.

I’ve tried with OpenXMLData, ReadXMLData with an extraction file

that I’m not positive how to build (samples I found don’t deal with

attributes at all).

I also tried with the XDOMOpen/Locate/etc. with no luck either. I’m

about to go off and parse this thing myself but thought I’d try the

list before I do.

Any help is appreciated!

TIA,

Robert

 

<?xml version=”1.0″ encoding=”utf-8″?>

<?xml-stylesheet type=”text/xsl” <?xml version=”1.0″ encoding=”UTF-16″?>

<?xml-stylesheet type=”text/xsl” href=”C:\IRIS2K1\Templates\SpecimenAnalysis-style.xsl”?>

<SA BF=”URN” ID=”021305941″ SID=”AP” OP=”gloa” ADT=”2005-06-08 16:03:32-08:00″ ADTS=”2005-06-08 16:03:32″ RDT=”2005-06-10 17:15:44-

08:00″ RDTS=”2005-06-10 17:15:44″ RP=”2″ SQN=”0″ RSQN=”28″ DILN=”1″ DILD=”1″ IMP=”0″ CDT=”2005-06-08 16:03:32-08:00″ CDTS=”2005-06-08

16:03:32″ REDT=”2005-06-08 16:13:31-08:00″ REDTS=”2005-06-08 16:13:31″>

<PF></PF>

<PF></PF>

<PF></PF>

<PF></PF>

<PF></PF>

<PF></PF>

<PF></PF>

<AC AT=”Chemistry” AS=”Done” SO=”External”>

<AR Key=”GLU” SN=”GLU” LN=”Glucose” AF=”0″ NR=”30″>Neg</AR>

<AR Key=”PRO” SN=”PRO” LN=”Protein” AF=”0″ NR=”30″>Neg</AR>

<AR Key=”BIL” SN=”BIL” LN=”Bilirubin” AF=”0″ NR=”1+”>Neg</AR>

<AR Key=”URO” SN=”URO” LN=”Urobilinogen” AF=”1″ NR=”1+”>3+</AR>

<AR Key=”PH” SN=”PH” LN=”pH” AF=”1″ NR=”5.0″>5.0</AR>

<AR Key=”BLD” SN=”BLD” LN=”Blood” AF=”0″ NR=”Trace”>Neg</AR>

<AR Key=”KET” SN=”KET” LN=”Ketone” AF=”1″ NR=”1+”>2+</AR>

<AR Key=”NIT” SN=”NIT” LN=”Nitrite” AF=”1″ NR=”Pos”>Pos</AR>

<AR Key=”LEU” SN=”LEU” LN=”Leukocytes” AF=”1″ NR=”1+”>4+</AR>

<AR Key=”CLA” SN=”CLA” LN=”Clarity” AF=”0″ NR=”Hazy”>Clear</AR>

<AR Key=”SG” SN=”SPGR” LN=”Specific Gravity” AF=”0″ NR=”1.040″>1.015</AR>

<AR Key=”COL” SN=”COL” LN=”Color” AF=”0″ NR=”Amber”>Colorless</AR>

</AC>

<AC AT=”Sediment” AS=”Done” SO=”Internal”>

<AR Key=”ART” SN=”ART” LN=”Artifact” AF=”0″ NR=”99999999 /LPF”>[none]</AR>

<AR Key=”RBC” SN=”RBC” LN=”Red Blood Cell” AF=”1″ NR=”4 /uL”>33 /uL</AR>

<AR Key=”WBC” SN=”WBC” LN=”White Blood Cell” AF=”0″ NR=”6 /HPF”>[none]</AR>

<AR Key=”WBCC” SN=”WBCC” LN=”White Blood Cell Clump” AF=”1″ NR=”Occ”>Many</AR>

<AR Key=”BACT” SN=”BACT” LN=”Bacteria” AF=”0″ NR=”Few”>Rare</AR>

<AR Key=”BYST” SN=”BYST” LN=”Budding Yeast” AF=”0″ NR=”Few”>[none]</AR>

<AR Key=”HYST” SN=”HYST” LN=”Hyphae Yeast” AF=”0″ NR=”Few”>[none]</AR>

<AR Key=”SQEP” SN=”SQEP” LN=”Squamous Epithelial” AF=”0″ NR=”16 /HPF”>[none]</AR>

<AR Key=”TREP” SN=”TREP” LN=”Transitional Epithelial” AF=”0″ NR=”1 /HPF”>[none]</AR>

<AR Key=”REEP” SN=”REEP” LN=”Renal Epithelial” AF=”0″ NR=”1 /HPF”>[none]</AR>

<AR Key=”OVFB” SN=”OVFB” LN=”Oval Fat Body” AF=”0″ NR=”1 /LPF”>1 /LPF</AR>

<AR Key=”FAT” SN=”FAT” LN=”Fat” AF=”0″ NR=”1 /LPF”>[none]</AR>

<AR Key=”MUCS” SN=”MUCS” LN=”Mucous” AF=”0″ NR=”999999999 /LPF”>[none]</AR>

<AR Key=”RBCC” SN=”RBCC” LN=”Red Blood Cell Clump” AF=”0″ NR=”1 /LPF”>[none]</AR>

<AR Key=”SPRM” SN=”SPRM” LN=”Sperm” AF=”0″ NR=”[none]”>Rare</AR>

<AR Key=”TRCH” SN=”TRCH” LN=”Trichomonas” AF=”0″ NR=”Present”>[none]</AR>

<AR Key=”NSE” SN=”NSE” LN=”Non-Squamous Epithelial” AF=”0″ NR=”1 /HPF”>&lt; 1 /HPF</AR>

<AR Key=”UNCC” SN=”UNCC” LN=”Unclassified Cast” AF=”0″ NR=”1 /LPF”>[none]</AR>

<AR Key=”HYAL” SN=”HYAL” LN=”Hyaline Cast” AF=”0″ NR=”3-5″>[none]</AR>

<AR Key=”EPIC” SN=”EPIC” LN=”Epithelial Cast” AF=”0″ NR=”1 /LPF”>[none]</AR>

<AR Key=”WBCT” SN=”WBCT” LN=”White Blood Cell Cast” AF=”0″ NR=”1 /LPF”>[none]</AR>

<AR Key=”RBCT” SN=”RBCT” LN=”Red Blood Cell Cast” AF=”0″ NR=”1 /LPF”>[none]</AR>

<AR Key=”GRAN” SN=”GRAN” LN=”Granular Cast” AF=”0″ NR=”1 /LPF”>[none]</AR>

<AR Key=”CELL” SN=”CELL” LN=”Cellular Cast” AF=”0″ NR=”1 /LPF”>[none]</AR>

<AR Key=”BROAD” SN=”BROAD” LN=”Broad Cast” AF=”0″ NR=”1 /LPF”>[none]</AR>

<AR Key=”FATC” SN=”FATC” LN=”Fatty Cast” AF=”0″ NR=”1 /LPF”>[none]</AR>

<AR Key=”WAXY” SN=”WAXY” LN=”Waxy Cast” AF=”0″ NR=”1 /LPF”>[none]</AR>

<AR Key=”UNCX” SN=”UNCX” LN=”Unclassified Crystal” AF=”0″ NR=”1 /HPF”>1 /HPF</AR>

<AR Key=”TPO4″ SN=”TPO4″ LN=”Triphosphate Crystal” AF=”0″ NR=”FEW”>[none]</AR>

<AR Key=”CAOX” SN=”CAOX” LN=”Calcium Oxalate Crystal” AF=”0″ NR=”FEW”>[none]</AR>

<AR Key=”CAPH” SN=”CAPH” LN=”Calcium Phosphate Crystal” AF=”0″ NR=”FEW”>[none]</AR>

<AR Key=”CACB” SN=”CACB” LN=”Calcium Carbonate Crystal” AF=”0″ NR=”FEW”>[none]</AR>

<AR Key=”URIC” SN=”URIC” LN=”Uric Acid Crystal” AF=”0″ NR=”FEW”>[none]</AR>

<AR Key=”LEUC” SN=”LEUC” LN=”Leucine Crystal” AF=”0″ NR=”POS”>[none]</AR>

<AR Key=”CYST” SN=”CYST” LN=”Cystine Crystal” AF=”0″ NR=”POS”>[none]</AR>

<AR Key=”TYRO” SN=”TYRO” LN=”Tyrosine Crystal” AF=”0″ NR=”POS”>[none]</AR>

<AR Key=”AMOR” SN=”AMOR” LN=”Amorphous Crystal” AF=”0″ NR=”FEW”>[none]</AR>

<AR Key=”UNCL” SN=”UNCL” LN=”Unclassified” AF=”0″ NR=”99999999 /LPF”>[none]</AR>

<AR Key=”PC” SN=”PC” LN=”PC” AF=”0″ NR=”[none]”>1314 /uL</AR>

</AC>

<FL>CHEMCONFIRM</FL>

<CM>This sample is contaminated!! Comment appears here!!!</CM>

<ARV>42</ARV>

</SA>

 

Example Code

 

$INCLUDE UNIVERSE.INCLUDE XML.H

*

EQU TRUE TO 1

EQU FALSE TO 0

*

DIM SA.AC.NODES(10)

SA.NODE.CNT = 1

*

RTN.CODE = XDOMOpen(“SAMPLE.XML”, XML.FROM.FILE, XDOM)

IF RTN.CODE = XML.SUCCESS THEN

CRT “XML Document opened”

;* read attribute “ID” from node “SA”

XPATH = “/SA”

ATT.ID = “ID”

GOSUB 100

IF NOT(ERR) THEN

CRT “SA, Attribute (ID) = <“:VALUE:”>.”

*

;****************************************************************

;* find all our nodes with a path of /SA/AC

;* and store them in our dimensioned array SA.AC.NODES

;****************************************************************

XPATH = “/SA/AC”

GOSUB 200

*

IF NOT(ERR) THEN

SA.AC.NODES(SA.NODE.CNT) = FND.NODE

NEW.NODE = FND.NODE

LOOP

RTN.CODE = XDOMLocateNode(NEW.NODE, XDOM.NEXT.SIBLING.WITH.SAME.NAME, 1,

XDOM.ELEMENT.NODE, NEW.NODE)

WHILE RTN.CODE = XML.SUCCESS

SA.NODE.CNT += 1

SA.AC.NODES(SA.NODE.CNT) = NEW.NODE

REPEAT

END

*

;****************************************************************

;* loop through our found nodes and find our “AR” children

;****************************************************************

FOR X = 1 TO SA.NODE.CNT

;* print out our AC, AT attribute value

FND.NODE = SA.AC.NODES(X)

ATT.ID = “AT”

GOSUB 300

CRT ” “:VALUE

*

;* find our “AR” node

RTN.CODE = XDOMLocate(SA.AC.NODES(X), “AR”, “”, FND.NODE)

GOSUB 400

*

LOOP

RTN.CODE = XDOMLocateNode(FND.NODE, XDOM.NEXT.SIBLING.WITH.SAME.NAME, 1,

XDOM.ELEMENT.NODE, FND.NODE)

WHILE RTN.CODE = XML.SUCCESS

;* locate our text node in “AR” to get results

GOSUB 400

REPEAT

NEXT X

END

END ELSE

CRT “ERROR: unable to open xml document!”

END

RETURN

 

Example Code (cont)

*

100: *** read attribute from node ***

*

* XPATH (IN): path of the node to read

* ATT.ID (IN): id of the attribute to get the value of

*

* VALUE (OUT): value of the attribute, otherwise “”

* ERR (OUT): true if an error occurred

*

ERR = FALSE

*

VALUE = “”

GOSUB 200

IF NOT(ERR) THEN

GOSUB 300

END

RETURN

*

200: *** locate node ***

*

* XPATH (IN): path of the node to read

*

* FND.NODE (OUT): node that was found

* ERR (OUT): true if an error occurred

*

ERR = FALSE

RTN.CODE = XDOMLocate(XDOM, XPATH, “”, FND.NODE)

IF RTN.CODE # XML.SUCCESS THEN

CRT “ERROR: unable to locate XPATH <“:XPATH:”>”

ERR = TRUE

END

RETURN

*

300: *** read attribute ***

*

* ATT.ID (IN) : attribute to read

* FND.NODE (IN) : node to read attribute from

*

* VALUE (OUT): value of the attribute, otherwise “”

* ERR (OUT): true if an error occurred

*

ERR = FALSE

RTN.CODE = XDOMGetAttribute(FND.NODE, ATT.ID, ATT.NODE)

IF RTN.CODE = XML.SUCCESS THEN

RTN.CODE = XDOMGetNodeValue(ATT.NODE, VALUE)

END ELSE

CRT “ERROR: unable to read attribute <“:ATT.ID:”>”

ERR = TRUE

END

RETURN

*

400: *** read results and display ***

*

;* locate our text node in “AR” to get results

RTN.CODE = XDOMLocateNode(FND.NODE, XDOM.CHILD, XDOM.FIRST.CHILD, XDOM.TEXT.NODE, TEXT.NODE)

RTN.CODE = XDOMGetNodeValue(TEXT.NODE, TEXT.VALUE)

*

ATT.ID = “Key”

GOSUB 300

CRT ” “:VALUE:” = “:TEXT.VALUE

RETURN

*

END

 

Output

XML Document opened

SA, Attribute (ID) = <021305941>.

Chemistry

GLU = Neg

PRO = Neg

BIL = Neg

URO = 3+

PH = 5.0

BLD = Neg

KET = 2+

NIT = Pos

LEU = 4+

CLA = Clear

SG = 1.015

COL = Colorless

Sediment

ART = [none]

RBC = 33 /uL

WBC = [none]

WBCC = Many

BACT = Rare

BYST = [none]

HYST = [none]

SQEP = [none]

TREP = [none]

REEP = [none]

OVFB = 1 /LPF

FAT = [none]

MUCS = [none]

RBCC = [none]

SPRM = Rare

TRCH = [none]

NSE = < 1 /HPF

UNCC = [none]

HYAL = [none]

EPIC = [none]

WBCT = [none]

RBCT = [none]

GRAN = [none]

CELL = [none]

BROAD = [none]

FATC = [none]

WAXY = [none]

UNCX = 1 /HPF

TPO4 = [none]

CAOX = [none]

CAPH = [none]

CACB = [none]

URIC = [none]

LEUC = [none]

CYST = [none]

TYRO = [none]

AMOR = [none]

UNCL = [none]

PC = 1314 /uL

Stop RF Gun Wireless disconnects

[From]: http://www.precisonline.com/forum/index.php/topic,245.0.html

We had a problem with our RF barcode scanners that we use in our warehouse for inventory: every once in a while, they’d lose the connection to the host.  Sometimes when the connection got dropped, they’d be in the middle of picking an order, and the dropped connection left the order in a messy state.

In order to mitigate this problem, we use screen http://www.manpagez.com/man/1/screen/ (AIX RPMs here: http://www.oss4aix.org/download/RPMS/screen/) to abstract the session on the RF device — if the connection drops, the same user can just log back in and resume the screen session.  One caveat — screen is for all intents and purposes a VT100 terminal emulator, so you have to make sure that whatever you’re connecting to (in our case Prelude) is expecting VT100, and the device you’re using is expecting the same.

To automate this, part of the login script for our RF gun users is:

#!/bin/sh
export TERM=vt100

if screen -ls | grep "No Sockets found" &gt; /dev/null 2&gt;&amp;1
  then
  screen -s /usr/local/bin/prelude.login
  exit 0
else
  SCREEN=`screen -ls | grep -v "screen" | awk '{print $1}'`
  echo "You are already logged on."
  echo "What do you want to do:"
  echo "1 - Resume Previous Session"
  echo "2 - Start a New Session"
  while [ ! "$yn" = "1" ] &amp;&amp; [ ! "$yn" = "2" ]
    do
    echo "Please enter 1 or 2."
    read yn
  done
  if [ "$yn" = "1" ]
    then
    screen -D -R $SCREEN
  fi
  if [ "$yn" = "2" ]
    then
    screen -s /usr/local/bin/prelude.login
  fi
fi

exit 0

Killing Unidata session (softly with STOPUDT)

[From]: http://ecolleague.blogspot.ca/2015/08/killing-unidata-session-softly-with.html

Killing Unidata session (softly with STOPUDT)

A while back when Colleague UI was first introduced, users started to X’ing out of the web-browser to close the session instead of using the logout button. That resulted in many runaways processes that used up the small license pool we had. I learned to kill those sessions through the terminal as following:

Open Colleague Desktop UI terminal:

LISTUSER: this lists all active sessions

LISTUSER | findusername“: this finds a particular user’s active sessions with “username”

Kill the session by:

STOPUDT usrnbr(user number): kill the session using the user’s number, it’s the number on the second column after using LISTUSER

* Note: insert a bang (“!”) in front of LISTUSER or STOPUDT to use admin right if the commands don’t work

You can use LISTUSER to check to see if your process is still running or the screen has frozen. Many times I waited for a process for so long just to find out the session was disconnected.