How to get a list of printers with their device address

2150 views
Skip to first unread message

Patrick Tonnerre

unread,
Oct 10, 2011, 10:42:49 AM10/10/11
to
Hi

my goal is to identify the lan printers which do not have an internet
name in RMTLOCNAME parameter into their device description.

For that, I need to produce a file (or a list) containing the device
name and its RMTLOCNAME parameter

All the lan printers name start with P, so the list will look like that:

PSGJGG 192.168.10.55
PKHKHKJ 192.168.10.75
PGDGDGD PDNSNAM01

I've tried a lot of thing :
- like found here
http://itknowledgeexchange.techtarget.com/itanswers/as400-printer-ip-address-listing/
but it do not fit my needs.

I do not succeed in getting that file/list.

Thank you for any help/ideas.
--
Patrick


JTF

unread,
Oct 12, 2011, 4:02:51 PM10/12/11
to
DSPOBJD OBJ(*ALL) OBJTYPE(*DEVD)
OUTPUT(*OUTFILE) OUTFILE(YourLib/YourFile)

This will give you all your devices
In the file, field ODOBAT gives you the attribute and I believe from looking at a sample I created, PRTLAN will the be device attribute you want....


Your host table (commonly edited by CFGTCP option 10) is actually
QATOCHOST with member HOSTS in library QUSRSYS

You can see if you have a match in the hostfile, otherwise remove the offending device from your system.

Patrick Tonnerre

unread,
Oct 17, 2011, 10:55:55 AM10/17/11
to
Hello

Le 12/10/2011 22:02, JTF a écrit :
> DSPOBJD OBJ(*ALL) OBJTYPE(*DEVD)
> OUTPUT(*OUTFILE) OUTFILE(YourLib/YourFile)
>
> This will give you all your devices
> In the file, field ODOBAT gives you the attribute and I believe from looking at a sample I created, PRTLAN will the be device attribute you want....

thank you, that command fills a file with all my printer.
But, it do not fit totally my needs.
For each printer in that file, i need to get the value of RMTLOCNAME
parameter of the device description.


> Your host table (commonly edited by CFGTCP option 10) is actually
> QATOCHOST with member HOSTS in library QUSRSYS
>
> You can see if you have a match in the hostfile, otherwise remove the offending device from your system.

My goal is to identify device descriptions with RMTLOCNAM containing an
IP adddress instead of a DNS name.

Thank You


CRPence

unread,
Oct 17, 2011, 1:36:24 PM10/17/11
to
On 17-Oct-2011 07:55 , Patrick Tonnerre wrote:
> Le 12/10/2011 22:02, JTF a écrit :
>> On 10-Oct-2011 07:42 , Patrick Tonnerre wrote:
>>>
>>> my goal is to identify the LAN printers which do not have an
>>> internet name in RMTLOCNAME parameter into their device
>>> description.
>>>
>>> For that, I need to produce a file (or a list) containing the
>>> device name and its RMTLOCNAME parameter
>>>
>>> All the lan printers name start with P, so the list will look
>>> like that:
>>>
>>> PSGJGG 192.168.10.55
>>> PKHKHKJ 192.168.10.75
>>> PGDGDGD PDNSNAM01
>>>
>>> I've tried a lot of thing : <<SNIP>>
>>>
>>> I do not succeed in getting that file/list. <<SNIP>>
> an IP address instead of a DNS name.
>

A "Remote location name type" of *IP, as provided by the Retrieve
Device Description (QDCRDEVD) API, will presumably give the desired
value for review.

Combining the above DSPOBJD with a SQL UDF, a SQL query report could
list the name, attribute, and Remote Location Name. A very rough and
limited example of what could be performed and an example of possible
output follows. Since data from the API can not generally be mapped
directly from raw data to typed data, a more prudent means instead,
would be to use an object list API combined with the device description
API to produce an external UDTF, producing a TABLE [function result] of
only printer device descriptions and perhaps only those with RMTLOCNAME
data. The following example might be functional [no IPV6 support as
coded] for the original intent without any modifications.

<code>

/* create callable interface to the API from SQL */
create procedure dcrdevd
( inout char(1800) for bit data, in int, in char(8)
, in char(10) , inout char(08) for bit data )
language CL parameter style general
external name qsys/qdcrdevd

/* create a UDF to return the specific DCRDEVD detail */
create function prtdrmtloc (devdnm char(10) ccsid 37)
returns char(255)
language sql not deterministic modifies sql data
returns null on null input
set option dbgview=*LIST
begin
declare rcvvar char(1800) for bit data not null default '';
declare rcvlen int not null default 1800;
declare apifmt char(08) not null default 'DEVD1100';
declare errcde char(08) for bit data not null
default x'0000000000000000';
declare devctg char(10) not null default '';
declare loctyp char(10) not null default '';
call dcrdevd ( rcvvar, rcvlen, apifmt, devdnm, errcde );
set devctg = substr(rcvvar, 32, 10);
set loctyp = substr(rcvvar, 1331, 10);
return case when (devctg='*PRT' and loctyp='*IP')
then substr( rcvvar, 1065, 255)
end;
end

/* generate a list of device descriptions; includes *PRT */
dspobjd *all *devd *full output(*outfile) outfile(qtemp/pd)

/* generate a report of devices with a "printer" attribute */
select odobnm,odobat,prtdrmtloc(odobnm)
from qtemp/pd
where odobat like '%PRT%'

....+....1....+....2....+....3....+....4 ...

Object Object PRTDRMTLOC
Attribute
PRT01 PRTLCL -
PRT02 PRTVRT -
RPRT01 PRTLAN 192.168.10.100
RPRT02 PRTLAN 192.168.10.110
SA77 PRTVRT -

</code>

Regards, Chuck

Jean-Marc Boisseau

unread,
Sep 26, 2020, 2:28:21 PM9/26/20
to
Thank you very much, very usefull :)
Reply all
Reply to author
Forward
0 new messages