<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: List users logged in - need way to split fields - perl? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050850#M96369</link>
    <description>&lt;!--!*#--&gt;&lt;BR /&gt;    while (&amp;lt;$dta&amp;gt;) {&lt;BR /&gt;        chomp;&lt;BR /&gt;        my @row = split m/\cB/ =&amp;gt; $_;&lt;BR /&gt;        my $s_time = "?";&lt;BR /&gt;        if ($row[2]) {&lt;BR /&gt;            my @tm = localtime $row[2];&lt;BR /&gt;            $s_time = sprintf "%2d-%02d-%4d %02d:%02d:%02d", $tm[3], $tm[4] + 1, $tm[5] + 1900, @tm[2,1,0];&lt;BR /&gt;            }&lt;BR /&gt;        printf $format, @row[0,1], $s_tim, "\n";&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
    <pubDate>Mon, 04 Jun 2007 12:57:51 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2007-06-04T12:57:51Z</dc:date>
    <item>
      <title>List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050836#M96355</link>
      <description>&lt;!--!*#--&gt;I run the following command (it grabs users logged in to servers via the security system we use)&lt;BR /&gt;&lt;BR /&gt;boksauth -Oresults -c FUNC=read TAB=5 FIELDS=\* |cat -v&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Output is an extremely long line, here's part of it:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA=CDRP:fapirwan^Bsvr607:pts/4^B^B1180963725^B^BCDRP_PROD:cdrbatch^Bsvr607:pts/5^B^B1180965178^B^BCISCO:kfulford^Btmonprod01:pts/1^B^B1180015709^B^BCISCO:kfulford^Btmonprod01:pts/2^B^B1180038015^B^BCORP_APPSRV:buckie^Bapptest2:pts/0^B^B1180966869^B^BDS_DATABASE_SERVERS:dbcorphd^Bsvr032:pts/15^B^B1173891966^B^B&lt;BR /&gt;&lt;BR /&gt;etc....etc...and then:&lt;BR /&gt;SPLIT=^B&lt;BR /&gt;FIELDS=USER TTY ROUTE TIME INFO&lt;BR /&gt;NRECORDS=669&lt;BR /&gt;$SERVCVER=6.0.3&lt;BR /&gt;&lt;BR /&gt;With awk, line is too long...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So, in the above,&lt;BR /&gt;&lt;BR /&gt;CDRP:fapirwan is the userid&lt;BR /&gt;svr607:pts/4 is the server and tty&lt;BR /&gt;1180963725 must be login time?&lt;BR /&gt;&lt;BR /&gt;Should look like:&lt;BR /&gt;&lt;BR /&gt;User          Tty          Time &lt;BR /&gt;CDRP:fapirwan pc0607:pts/4 06/04/07 07:28:45 &lt;BR /&gt;&lt;BR /&gt;Which is what I get from teh "web page" - but I want to do it from the command line instead...&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;&lt;BR /&gt;I'm pretty sure perl is the answer (isn't it the answer to everything?)&lt;BR /&gt;&lt;BR /&gt;I think this is one for my friend Hein.&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Jun 2007 09:55:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050836#M96355</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T09:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050837#M96356</link>
      <description>&lt;!--!*#--&gt;if&lt;BR /&gt;&lt;BR /&gt; while (&amp;lt;&amp;gt;) {&lt;BR /&gt;     my @row = split m/\cB/ =&amp;gt; $_;&lt;BR /&gt;     print "first field: ", $row[0], "\n";&lt;BR /&gt;     }&lt;BR /&gt;&lt;BR /&gt;doesn't work, you might like to have a look at Text::CSV_XS&lt;BR /&gt;&lt;BR /&gt; use IO::Handle;&lt;BR /&gt; use Text::CSV_XS;&lt;BR /&gt; my $csv = Text::CSV_XS-&amp;gt;new ({ sep_char =&amp;gt; "\cB", binary =&amp;gt; 1 });&lt;BR /&gt; while (my $row = $csv-&amp;gt;getline (*ARGV) {&lt;BR /&gt;     print "first field: ", $row-&amp;gt;[0], "\n";&lt;BR /&gt;     }&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 04 Jun 2007 10:04:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050837#M96356</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2007-06-04T10:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050838#M96357</link>
      <description>Merijn,&lt;BR /&gt;&lt;BR /&gt;Well - I tried:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;foreach (`boksauth -Oresults -c FUNC=read TAB=5 FIELDS=\* |cat -v`) {&lt;BR /&gt;        chomp;&lt;BR /&gt;        my @row = split m/\cB/ =&amp;gt; $_;&lt;BR /&gt;        print "first field: ", $row[0], "\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Just adds first field: to front of each line...doesn't seem to split on the ^B&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 04 Jun 2007 10:13:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050838#M96357</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T10:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050839#M96358</link>
      <description>&lt;!--!*#--&gt;cat -v is munging you Ctrl-B to being not binary anymore :)&lt;BR /&gt;&lt;BR /&gt;Then you're using foreach, which will read the whole dataset at once. And don't use backticks when you can do without.&lt;BR /&gt;&lt;BR /&gt;open my $dta, "-|", 'boksauth -Oresults -c FUNC=read TAB=5 FIELDS=\*' or die "$!";&lt;BR /&gt;while (&amp;lt;$dta&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    my @row = split m/\cB/ =&amp;gt; $_;&lt;BR /&gt;    print "first field: ", $row[0], "\n";&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 04 Jun 2007 10:41:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050839#M96358</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2007-06-04T10:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050840#M96359</link>
      <description>Cool - getting closer...&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;$format="%20s %20s %20s\n";&lt;BR /&gt;printf $format, "Userid","Server:TTY","Time";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;open my $dta, "-|", 'boksauth -Oresults -c FUNC=read TAB=5 FIELDS=\*' or die "$!";&lt;BR /&gt;while (&amp;lt;$dta&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    my @row = split m/\cB/ =&amp;gt; $_;&lt;BR /&gt;    printf $format, $row[0], $row[1], $row[2], "\n";&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Only get first row...how to get the rest?&lt;BR /&gt;&lt;BR /&gt;Rgds....Geoff</description>
      <pubDate>Mon, 04 Jun 2007 11:44:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050840#M96359</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T11:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050841#M96360</link>
      <description>You should get all of the rows, unless the rows are not sperated by newlines.&lt;BR /&gt;&lt;BR /&gt;The *field*seperator is a Ctrl-B, your snippet deals with the data as if the *record*separator is a \n (newline). If it is not, but e.g. it is a Ctrl-C, add&lt;BR /&gt;&lt;BR /&gt; if (open my $dta, ...&lt;BR /&gt;     local $/ = "\cC";&lt;BR /&gt;     while (&amp;lt;$dta&amp;gt;) {&lt;BR /&gt;         :&lt;BR /&gt;         }&lt;BR /&gt;     }&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 04 Jun 2007 11:51:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050841#M96360</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2007-06-04T11:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050842#M96361</link>
      <description>That's correct - for some reason there is no new lines (strange output I know).&lt;BR /&gt;&lt;BR /&gt;With the cat -v - it looks like each "line" is separated by 2 ^B's  ???&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 04 Jun 2007 12:14:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050842#M96361</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T12:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050843#M96362</link>
      <description>if there are no empty fields, you can set the line sep to "\cB\cB", and the rest will still work ok.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 04 Jun 2007 12:20:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050843#M96362</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2007-06-04T12:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050844#M96363</link>
      <description>&lt;!--!*#--&gt;You are getting me close - now just a format issue and I guess I need to convert the login time from for example "1180963725" to "06/04/07 07:28:45"&lt;BR /&gt;&lt;BR /&gt;Here's the current script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;$format="%20s %20s %20s\n";&lt;BR /&gt;printf $format, "Userid","Server:TTY","Time";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if (open my $dta, "-|", 'boksauth -Oresults -c FUNC=read TAB=5 FIELDS=\*|head -1' or die "$!"){&lt;BR /&gt;local $/ = "\cB";&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;$dta&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    my @row = split m/\cB/ =&amp;gt; $_;&lt;BR /&gt;    printf $format, $row[0], $row[1], $row[2], "\n";&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Part of output:&lt;BR /&gt;&lt;BR /&gt;# ./z |more&lt;BR /&gt;              Userid           Server:TTY                 Time&lt;BR /&gt;  DATA=CDRP:fapirwan&lt;BR /&gt;        svr607:pts/4&lt;BR /&gt;&lt;BR /&gt;          1180963725&lt;BR /&gt;&lt;BR /&gt;  CDRP_PROD:cdrbatch&lt;BR /&gt;        svr607:pts/5&lt;BR /&gt;&lt;BR /&gt;          1180965178&lt;BR /&gt;&lt;BR /&gt; CISCOWORKS:kfulford&lt;BR /&gt;    tmonprod01:pts/1&lt;BR /&gt;&lt;BR /&gt;          1180015709&lt;BR /&gt;&lt;BR /&gt; CISCOWORKS:kfulford&lt;BR /&gt;    tmonprod01:pts/2&lt;BR /&gt;&lt;BR /&gt;          1180038015&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 04 Jun 2007 12:28:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050844#M96363</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T12:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050845#M96364</link>
      <description>Interesting, this &lt;BR /&gt;&lt;BR /&gt;printf $format, $row[0], $row[1], $row[2], "\n";&lt;BR /&gt;&lt;BR /&gt;is now the same as&lt;BR /&gt;&lt;BR /&gt;printf $format, $row[0];&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;IE - same output...&lt;BR /&gt;&lt;BR /&gt;I guess the local $/ = "\cB"; is changing  what is split....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 04 Jun 2007 12:35:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050845#M96364</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T12:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050846#M96365</link>
      <description>&lt;!--!*#--&gt;Why the | head -1?&lt;BR /&gt;And the last shot only showed a single \cB in $/&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;my $format = "%20s %20s %20s\n";&lt;BR /&gt;printf $format, "Userid", "Server:TTY", "Time";&lt;BR /&gt;&lt;BR /&gt;if (open my $dta, "-|", 'boksauth -Oresults -c FUNC=read TAB=5 FIELDS=\*|head -1' or die "$!") {&lt;BR /&gt;    local $/ = "\cB\cB";&lt;BR /&gt;&lt;BR /&gt;    while (&amp;lt;$dta&amp;gt;) {&lt;BR /&gt;        chomp;&lt;BR /&gt;        my @row = split m/\cB/ =&amp;gt; $_;&lt;BR /&gt;        my @tm = localtime $row[2]; # Assuming unix time stamps&lt;BR /&gt;        printf $format, @row[0,1],&lt;BR /&gt;            sprintf ("%2d-%02d-%4d %02d:%02d:%02d",&lt;BR /&gt;                $tm[3], $tm[4] + 1, $tm[5] + 1900,&lt;BR /&gt;                @tm[2,1,0]), "\n";&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 04 Jun 2007 12:39:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050846#M96365</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2007-06-04T12:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050847#M96366</link>
      <description>the head -1 to get rid of the extra data fromt the command:&lt;BR /&gt;&lt;BR /&gt;SPLIT=&lt;BR /&gt;FIELDS=USER TTY ROUTE TIME INFO&lt;BR /&gt;NRECORDS=688&lt;BR /&gt;$SERVCVER=6.0.3&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 04 Jun 2007 12:40:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050847#M96366</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T12:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050848#M96367</link>
      <description>Hi Geoff:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I guess I need to convert the login time from for example "1180963725" to "06/04/07 07:28:45"&lt;BR /&gt;&lt;BR /&gt;That's easily added:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use POSIX qw (strftime);&lt;BR /&gt;&lt;SNIP&gt;&lt;BR /&gt;printf "%-20s\n", strftime "%m/%d/%Y %T",localtime($time);&lt;BR /&gt;&lt;SNIP&gt;&lt;BR /&gt;&lt;BR /&gt;...where $time is the field representing your Epoch seconds.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;/SNIP&gt;&lt;/SNIP&gt;</description>
      <pubDate>Mon, 04 Jun 2007 12:48:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050848#M96367</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-06-04T12:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050849#M96368</link>
      <description>Okay - looking better - I get a bunch of:&lt;BR /&gt;&lt;BR /&gt;Use of uninitialized value in localtime at ./zz line 15, &amp;lt;$dta&amp;gt; chunk 1036.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 16, &amp;lt;$dta&amp;gt; chunk 1036.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  DATA=CDRP:fapirwan         svr607:pts/4  31-12-1969 17:00:00&lt;BR /&gt;          1180963725                       31-12-1969 17:00:00&lt;BR /&gt;  CDRP_PROD:cdrbatch         svr607:pts/5  31-12-1969 17:00:00&lt;BR /&gt;          1180965178                       31-12-1969 17:00:00&lt;BR /&gt; CISCOWORKS:kfulford     tmonprod01:pts/1  31-12-1969 17:00:00&lt;BR /&gt;          1180015709                       31-12-1969 17:00:00&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Jun 2007 12:49:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050849#M96368</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T12:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050850#M96369</link>
      <description>&lt;!--!*#--&gt;&lt;BR /&gt;    while (&amp;lt;$dta&amp;gt;) {&lt;BR /&gt;        chomp;&lt;BR /&gt;        my @row = split m/\cB/ =&amp;gt; $_;&lt;BR /&gt;        my $s_time = "?";&lt;BR /&gt;        if ($row[2]) {&lt;BR /&gt;            my @tm = localtime $row[2];&lt;BR /&gt;            $s_time = sprintf "%2d-%02d-%4d %02d:%02d:%02d", $tm[3], $tm[4] + 1, $tm[5] + 1900, @tm[2,1,0];&lt;BR /&gt;            }&lt;BR /&gt;        printf $format, @row[0,1], $s_tim, "\n";&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 04 Jun 2007 12:57:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050850#M96369</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2007-06-04T12:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050851#M96370</link>
      <description>Line 20 is:&lt;BR /&gt;&lt;BR /&gt;printf $format, @row[0,1], $s_time, "\n";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Maybe, it's not row[2]?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;              Userid           Server:TTY                 Time&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 2.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 4.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 6.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 8.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 10.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 12.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 14.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 16.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 18.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 20.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 22.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 24.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 26.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 28.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 30.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 32.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 34.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 36.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 38.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 40.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 42.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 44.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 46.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 48.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 50.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 52.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 54.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 56.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 58.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 60.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 62.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 64.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 66.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 68.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 70.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 72.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 74.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 76.&lt;BR /&gt;Use of uninitialized value in printf at ./zz line 20, &amp;lt;$dta&amp;gt; chunk 78.&lt;BR /&gt;  DATA=CDRP:fapirwan         svr607:pts/4                    ?&lt;BR /&gt;          1180963725                                         ?&lt;BR /&gt;  CDRP_PROD:cdrbatch         svr607:pts/5                    ?&lt;BR /&gt;          1180965178                                         ?&lt;BR /&gt; CISCOWORKS:kfulford     tmonprod01:pts/1                    ?&lt;BR /&gt;          1180015709                                         ?&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Jun 2007 13:06:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050851#M96370</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T13:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050852#M96371</link>
      <description>&lt;!--!*#--&gt;If I &lt;BR /&gt;&lt;BR /&gt;print $row[0];&lt;BR /&gt;&lt;BR /&gt;then I get one long output...&lt;BR /&gt;&lt;BR /&gt;DATA=CDRP:fapirwansvr607:pts/41180963725CDRP_PROD:cdrbatchsvr607:pts/51180965178CISCOWORKS:kfulfordtmonprod01:pts/1118001570&lt;BR /&gt;9&lt;BR /&gt;&lt;BR /&gt;If I:&lt;BR /&gt;&lt;BR /&gt;print $row[0],"\n";&lt;BR /&gt;&lt;BR /&gt;              Userid           Server:TTY                 Time&lt;BR /&gt;DATA=CDRP:fapirwan&lt;BR /&gt;svr607:pts/4&lt;BR /&gt;&lt;BR /&gt;1180963725&lt;BR /&gt;&lt;BR /&gt;CDRP_PROD:cdrbatch&lt;BR /&gt;svr607:pts/5&lt;BR /&gt;&lt;BR /&gt;1180965178&lt;BR /&gt;&lt;BR /&gt;CISCOWORKS:kfulford&lt;BR /&gt;tmonprod01:pts/1&lt;BR /&gt;&lt;BR /&gt;1180015709&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If I try &lt;BR /&gt;print $row[2];&lt;BR /&gt;&lt;BR /&gt;I get nada....&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Jun 2007 13:16:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050852#M96371</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T13:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050853#M96372</link>
      <description>&lt;!--!*#--&gt;Okay - just doing some troubleshooting...&lt;BR /&gt;&lt;BR /&gt;If I:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;$format="%20s %20s %20s\n";&lt;BR /&gt;printf $format, "Userid","Server:TTY","Time";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if (open my $dta, "-|", 'boksauth -Oresults -c FUNC=read TAB=5 FIELDS=\*|head -1' or die "$!"){&lt;BR /&gt;local $/ = "\cB\cB";&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;$dta&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    my @row = split m/\cB/ =&amp;gt; $_;&lt;BR /&gt;     printf $format, $row[0], $row[1];&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Output is:&lt;BR /&gt;&lt;BR /&gt;# ./z |more&lt;BR /&gt;              Userid           Server:TTY                 Time&lt;BR /&gt;  DATA=CDRP:fapirwan         svr607:pts/4&lt;BR /&gt;          1180963725&lt;BR /&gt;  CDRP_PROD:cdrbatch         svr607:pts/5&lt;BR /&gt;          1180965178&lt;BR /&gt; CISCOWORKS:kfulford     tmonprod01:pts/1&lt;BR /&gt;          1180015709&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;What that tells me is, DATA=CDRP:fapirwan is row[0] and svr607:pts/4 is row[1].&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For some reason, the time is also row[0]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Looking at the orig data:&lt;BR /&gt;&lt;BR /&gt;# boksauth -Oresults -c FUNC=read TAB=5 FIELDS=\*|cat -v&lt;BR /&gt;DATA=CDRP:fapirwan^Bsvr607:pts/4^B^B1180963725^B^BCDRP_PROD:cdrbatch&lt;BR /&gt;&lt;BR /&gt;we see 2 ^B's before AND after the time field   :(&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Jun 2007 13:26:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050853#M96372</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T13:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050854#M96373</link>
      <description>&lt;!--!*#--&gt;Here's where I am now:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;my $digits = '\d+';&lt;BR /&gt;&lt;BR /&gt;my $format = "%20s %20s %20s\n";&lt;BR /&gt;printf $format, "Userid", "Server:TTY", "Time";&lt;BR /&gt;&lt;BR /&gt;if (open my $dta, "-|", 'boksauth -Oresults -c FUNC=read TAB=5 FIELDS=\*|head -1' or die "$!") {&lt;BR /&gt;    local $/ = "\cB\cB";&lt;BR /&gt;&lt;BR /&gt;    while (&amp;lt;$dta&amp;gt;) {&lt;BR /&gt;        chomp;&lt;BR /&gt;        my @row = split m/\cB/ =&amp;gt; $_;&lt;BR /&gt;        my $s_time = "?";&lt;BR /&gt;        if ($row[0] =~ $digits) {&lt;BR /&gt;            my @tm = localtime $row[0];&lt;BR /&gt;            $s_time = sprintf "%2d-%02d-%4d %02d:%02d:%02d", $tm[3], $tm[4] + 1, $tm[5] + 1900, @tm[2,1,0];&lt;BR /&gt;        }&lt;BR /&gt;        else {&lt;BR /&gt;            $s_time = " ";&lt;BR /&gt;            }&lt;BR /&gt;        printf $format, @row[0,1], $s_time, "\n";&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I still get a lot of &lt;BR /&gt;&lt;BR /&gt;Use of uninitialized value in print at ./zz line 25, &amp;lt;$dta&amp;gt; chunk 870.&lt;BR /&gt;&lt;BR /&gt;And format not quite right:&lt;BR /&gt;&lt;BR /&gt;  DATA=CDRP:fapirwan         svr607:pts/4&lt;BR /&gt;          1180963725                        4-06-2007 07:28:45&lt;BR /&gt;  CDRP_PROD:cdrbatch         svr607:pts/5&lt;BR /&gt;          1180965178                        4-06-2007 07:52:58&lt;BR /&gt; CISCOWORKS:kfulford     tmonprod01:pts/1&lt;BR /&gt;          1180015709                       24-05-2007 08:08:29&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It would be nice to somehow join the time field to be on same line as the first 2 fields...and not print out the "Unix" time at all - just the converted time...&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Jun 2007 14:07:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050854#M96373</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2007-06-04T14:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: List users logged in - need way to split fields - perl?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050855#M96374</link>
      <description>&lt;!--!*#--&gt;That should be easy, but a little tricky with the actual data. [attach?]&lt;BR /&gt;It seems to me there is a new line coming from the $format, as well as from a print argument.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here what works for me, after replacing th ^B^B in the sample line with ~ and ^B with and just 'typing' the dataline ;&lt;BR /&gt;&lt;BR /&gt;C:\temp&amp;gt;perl y.pl&lt;BR /&gt;              Userid           Server:TTY                 Time&lt;BR /&gt;       CDRP:fapirwan         svr607:pts/4   4-06-2007 09:28:45&lt;BR /&gt;  CDRP_PROD:cdrbatch         svr607:pts/5   4-06-2007 09:52:58&lt;BR /&gt;      CISCO:kfulford     tmonprod01:pts/1  24-05-2007 10:08:29&lt;BR /&gt;      CISCO:kfulford     tmonprod01:pts/2  24-05-2007 16:20:15&lt;BR /&gt;  CORP_APPSRV:buckie       apptest2:pts/0   4-06-2007 10:21:09&lt;BR /&gt;DS_DATABASE_SERVERS:dbcorphd        svr032:pts/15  14-03-2007 13:06:06&lt;BR /&gt;&lt;BR /&gt;-------------- y.pl -------------------&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $format = "%20s %20s %20s\n";&lt;BR /&gt;printf $format, "Userid", "Server:TTY", "Time";&lt;BR /&gt;&lt;BR /&gt;if (open my $dta, "-|", 'boksauth -Oresults -c FUNC=read TAB=5 FIELDS=\*|head -1' or die "$!") {&lt;BR /&gt;    local $/ = "\cB\cB";&lt;BR /&gt;&lt;BR /&gt;    while (&amp;lt;$dta&amp;gt;) {&lt;BR /&gt;        chomp;&lt;BR /&gt;        my @row = split m/\cB/ =&amp;gt; $_;&lt;BR /&gt;        my $s_time = "?";&lt;BR /&gt;        if ($row[0] =~ $digits) {&lt;BR /&gt;            my @tm = localtime $row[0];&lt;BR /&gt;            $s_time = sprintf "%2d-%02d-%4d %02d:%02d:%02d", $tm[3], $tm[4] + 1, $tm[5] + 1900, @tm[2,1,0];&lt;BR /&gt;        }&lt;BR /&gt;        else {&lt;BR /&gt;            $s_time = " ";&lt;BR /&gt;            }&lt;BR /&gt;        printf $format, @row[0,1], $s_time, "\n";&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;--------------- real code ?? --------------&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;my $format = "%20s %20s %20s\n";&lt;BR /&gt;printf $format, "Userid", "Server:TTY", "Time";&lt;BR /&gt;&lt;BR /&gt;my (@row, $i);&lt;BR /&gt;&lt;BR /&gt;open my $dta, "-|", 'boksauth -Oresults -c FUNC=read TAB=5 FIELDS=\*|head -1' or die "$!";&lt;BR /&gt;local $/ = "\cB\cB";&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;$dta&amp;gt;) {&lt;BR /&gt;    chomp;  &lt;BR /&gt;    s/^DATA=// unless $i++;     # clean up header on first entry&lt;BR /&gt;    if (/^(\d+)/) {             # line with timestamp ?&lt;BR /&gt;        my @tm = localtime $1;&lt;BR /&gt;        my $s_time = sprintf "%2d-%02d-%4d %02d:%02d:%02d", &lt;BR /&gt;             $tm[3], $tm[4] + 1, $tm[5] + 1900, @tm[2,1,0];&lt;BR /&gt;        printf $format, @row[0,1], $s_time;&lt;BR /&gt;    } else {&lt;BR /&gt;        @row = split m/\cB/;&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Good luck!</description>
      <pubDate>Mon, 04 Jun 2007 16:03:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/list-users-logged-in-need-way-to-split-fields-perl/m-p/5050855#M96374</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-06-04T16:03:04Z</dc:date>
    </item>
  </channel>
</rss>

