Hi , I am using the Net::SSH::Perl Module to execute the "w" command on the remote machine . I am getting the result on the display screen after executing my perl script as shown below.
USER TTY FROM LOGIN@ IDLE JCPU PCPU root tty1 - 6:28am 1:04 1.04s 0.02s man tty2 - 6:28am 15:59 0.05s 0.03s jen tty3 - 6:28am 15:55 0.17s 0.05s
But I want to search only for root priviledged user's from the "w" command ."w" command lists all the user's who are logged to the remote machine including those without root priviledges.Like in the result shown above user "man" is not root priviledged user. How can I do that using the "w" command results. Also I want to search in the sshd.log or the messages log files so that i can get the disconnect time for the particular user who has logged out . Here is an example to illustrate what I want to achieve using Net::SSH::Perl module : If "w" output shows 3 user's logged in to the remote machine like the one shown above then I want to first check whether the user "man" is root priviledged or not .If the user "man" is root priviledged user then I want to search in the sshd.log or messages log files to remove the time of connect and disconnect time for the user "man". If the user "man" is not root priviledged user then no search is to be performed . Same with the user "jen" . How can I add a column to the above result to show the user disconnect time . I want the final display like :
USER TTY FROM LOGIN@ IDLE JCPU PCPU Disconnect root tty1 - 6:28am 1:04 1.04s 0.02s 6:45am man tty2 - 6:28am 15:59 0.05s 0.03s 7:10am jen tty3 - 6:28am 15:55 0.17s 0.05s 6:30am
I tried using grep and cut but with no success. Please suggest me on the above problem . Thankyou !

In reply to Net::SSH::Perl Help by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.