<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl  
#Process-Detail-0.1.pl
#This is a script which is coded by Sujai Sojan to provide detailed information 
#about processes running in a linux machine. It has options to list the hidden 
#processes also
#Sujai Sojan &lt;sujai@logicsupport.com&gt;


use Switch;
$VERSION = 0.1;

$dir="/proc";
opendir(DIR,"$dir");


sub hidden
{
print "\n##########Hidden processlist###############\n\n";
foreach $pcs (readdir(DIR))
{
if($pcs =~ /(\d+)/ &amp;&amp; $pcs =~ /\./)
{
&amp;detailedview("$pcs");
}
}
}

sub all
{
foreach $pcs (readdir(DIR))
{
&amp;detailedview("$pcs");
}
}

sub detailedview
{
@args=@_;
$envir="/proc/$args[0]/environ";
$stat="/proc/$args[0]/status";
open(CMD,"/proc/$args[0]/cmdline");
my @array=&lt;CMD&gt;;
foreach my $cmd (@array)
{
print "\n\nPID=$args[0]\n";
print "COMMAND=$cmd\n";
}

open(FILE,"&lt;$envir");
while(&lt;FILE&gt;)
{
@array=split(/([A-Z]+(_|[A-Z])+\=.[^A-Z]+)/,$_);
foreach $splitted (@array)
{
if($splitted =~ /\=/)
{
print "$splitted\n";
}
}
}
open(FILESTAT,"&lt;$stat");
while(&lt;FILESTAT&gt;)
{
if(/(State|PPid|Gid|Uid)/)
{
print $_;
}
}

print "\n\n\n###########################################\n\n\n";
close(FILE);
}

sub usage
{
print "\nUsage:\n-h\tFor detailed view hidden process\n-a\tFor detailed view of all processes\n-p pid\tFor detailed view of process with processid pid\n--help\tFor help\n-V\tFor checking Version\n\n ";
}
if ($#ARGV le -1)

{
  &amp;usage;
  exit;
}
else
{
switch ($ARGV[0])
{
case "-h" { &amp;hidden;}
case "-p" { &amp;detailedview($ARGV[1]);}
case "-a" { &amp;all;}
case "-V" { print "\nProcess-Detail Version 0.1\n\n" ;}
case "--help" { &amp;usage;}
else { &amp;usage;}
}
}

=head1 NAME

Process-Detail

=head1 AUTHOR
Sujai Sojan &lt;sujai@logicsupport.com&gt;

=head1 DESCRIPTION

This is a script which is coded by Sujai Sojan to provide detailed 
information about processes running in a linux machine.
It has options to list the hidden processes also



=head1 PREREQUISITES

use Switch;


=pod OSNAMES

Linux

=pod SCRIPT CATEGORIES

Unix/System_administration

=cut



</pre></body></html>