2.3.2 Example for listing software assets of installed programs that are not authorized
This subsection provides an example of listing the assets of software not authorized to be installed, along with the unauthorized programs, and outputting the list to a file. To create the list, this example performs a search that uses the [JOIN_FIND] tag to join multiple classes.
-
Sample output file
The following are the contents output to file by the example in this subsection:
"Software name","Version","Asset No.","Group information","User" "SoftwareA","0100","0000000001","Head Office/Sales Dept./Section 1","user1" "SoftwareA","0101","0000000001","Head Office/Sales Dept./Section 1","user1" "SoftwareB","0100","0000000001","Head Office/Sales Dept./Section 1","user1" "SoftwareA","0100","0000000002","Head Office/Sales Dept./Section 2","user2"
#AssetInformationManager HTML 0005
#===============================================================================
# Variable definitions
#===============================================================================
[VAR]
STATUS
DUMMY
WORK
ECHOMSG
MSG
FILENAME
[SET_VALUE]
MSG = $GETSESSION('MSG')
#===============================================================================
# Output of information on unauthorized software to CSV file (main)
#===============================================================================
[BEGIN]
[VAR]
ASSET_NO
GROUP
USER
SOFTNAME
SOFTVR
FH
LINE
[ARRAY]
OUTLINE
[SET_VALUE]
FILENAME = $GETSESSION('CSV')
FH = $FILEOPEN(FILENAME, RENEW)
$SETARRAY(OUTLINE,'Software name')
$SETARRAY(OUTLINE,'Version')
$SETARRAY(OUTLINE,'Asset No.')
$SETARRAY(OUTLINE,'Group name')
$SETARRAY(OUTLINE,'User')
$FILEARRAY(FH, OUTLINE)
$CLEARARRAY(OUTLINE)
LINE = 0
[TRANSACTION]
[ASSET_ITEM_LOOP]
[JOIN_FIND]
[JOIN]
joinassoc;InstalledListLink;
joinfrom;InstalledList,InstalledInfo;
jointype;INNER;
[JOIN]
joinassoc;InstalledLink;
joinfrom;InstalledInfo,AssetInfo;
jointype;INNER;
[JOIN]
joinfrom;AssetInfo,GroupInfo;
jointype;OUTER;
joinkey;AssetInfo.GroupID,GroupInfo.GroupID;
[FIND_DATA]
(InstalledList.InstalledPermit = '2')
[GET_VALUE]
SOFTNAME = InstalledList.InstalledName
SOFTVR = InstalledList.InstalledVersion
ASSET_NO = AssetInfo.AssetNo
GROUP = GroupInfo.FullPathName
USER = AssetInfo.UserName
[SET_VALUE]
$SETARRAY(OUTLINE,SOFTNAME)
$SETARRAY(OUTLINE,SOFTVR)
$SETARRAY(OUTLINE,ASSET_NO)
$SETARRAY(OUTLINE,GROUP)
$SETARRAY(OUTLINE,USER)
$FILEARRAY(FH, OUTLINE)
$CLEARARRAY(OUTLINE)
LINE = $ADD(LINE, 1)
[ASSET_ITEM_LOOP_END]
[SET_VALUE]
$SETSTATUS('NORMAL')
[TRANSACTION_END]
[SET_VALUE]
$FILECLOSE(FH)
[IF]
(LINE = 0)
[THEN]
[SET_VALUE]
ECHOMSG = 'No data found.'
$ECHO(ECHOMSG)
$EXIT(1)
[ELSE]
[SET_VALUE]
ECHOMSG = LINE+' items of data output'
$ECHO(ECHOMSG)
[IF_END]
[END]