<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.scott5.org/index.php?action=history&amp;feed=atom&amp;title=Example_Perl_Scripts</id>
	<title>Example Perl Scripts - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.scott5.org/index.php?action=history&amp;feed=atom&amp;title=Example_Perl_Scripts"/>
	<link rel="alternate" type="text/html" href="https://wiki.scott5.org/index.php?title=Example_Perl_Scripts&amp;action=history"/>
	<updated>2026-04-13T00:05:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://wiki.scott5.org/index.php?title=Example_Perl_Scripts&amp;diff=207&amp;oldid=prev</id>
		<title>Scott: Created page with &#039;&lt;source lang=&quot;perl&quot;&gt; #!/usr/bin/perl # A script to list which users are actually using the system right now  use Text::ParseWords;  my @ps_list = `ps -ef`; foreach $line (@ps_lis…&#039;</title>
		<link rel="alternate" type="text/html" href="https://wiki.scott5.org/index.php?title=Example_Perl_Scripts&amp;diff=207&amp;oldid=prev"/>
		<updated>2011-02-01T18:47:28Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt; #!/usr/bin/perl # A script to list which users are actually using the system right now  use Text::ParseWords;  my @ps_list = `ps -ef`; foreach $line (@ps_lis…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/perl&lt;br /&gt;
# A script to list which users are actually using the system right now&lt;br /&gt;
&lt;br /&gt;
use Text::ParseWords;&lt;br /&gt;
&lt;br /&gt;
my @ps_list = `ps -ef`;&lt;br /&gt;
foreach $line (@ps_list){&lt;br /&gt;
    #print($line);&lt;br /&gt;
    my @tokens = shellwords($line);&lt;br /&gt;
    my $cpu_score = $tokens[3];&lt;br /&gt;
    if ($cpu_score &amp;gt; 0){&lt;br /&gt;
        my $user = $tokens[0];&lt;br /&gt;
        if ($user ne &amp;quot;root&amp;quot;){&lt;br /&gt;
            print($line);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/perl -w&lt;br /&gt;
# return semi-colon-delimited list of non-system usernames&lt;br /&gt;
use Text::ParseWords;&lt;br /&gt;
&lt;br /&gt;
my $output = &amp;quot;&amp;quot;;&lt;br /&gt;
my $started = 0;&lt;br /&gt;
open(PW, &amp;quot;/etc/passwd&amp;quot;) or die &amp;quot;failed to open /etc/passwd&amp;quot;;&lt;br /&gt;
while (my $line = &amp;lt;PW&amp;gt;){&lt;br /&gt;
    chomp $line;&lt;br /&gt;
    my @list = quotewords(&amp;quot;:&amp;quot;, 1, $line);&lt;br /&gt;
    my $user = $list[0];&lt;br /&gt;
    my $id = $list[2];&lt;br /&gt;
    if ($id &amp;gt; 100){&lt;br /&gt;
    #print &amp;quot;user $user, id $id\n&amp;quot;;&lt;br /&gt;
        if ($started){&lt;br /&gt;
            $output .= &amp;quot;;$user&amp;quot;;&lt;br /&gt;
        } else {&lt;br /&gt;
            $output .= $user;&lt;br /&gt;
        }&lt;br /&gt;
    $started = 1;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
print $output;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Scott</name></author>
	</entry>
</feed>