Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Another Server Info Snooper (AsIs) ;)

by Alexander (Sexton)
on Jun 26, 2006 at 17:32 UTC ( #557617=sourcecode: print w/replies, xml ) Need Help??
Category: CGI Programming
Author/Contact Info Alexander
Description: Snoops some useful information which I have not normally seen included in other such utilities. It can be handy to web developers to have such system summaries. Particularly to those of us on shared hosting accounts or virtual private servers that sometimes can require configuring certain things to operate properly within the account user's $HOME. I personally find myself needing to do that sometimes. In doing it recently, I wrote this utility, and then ran it past the CB before posting it here. (See credits, line 3.) It's summary is intended to be customizable by the user to have the values they need at a glance. Because it will accept ANY shell command, it is potentially dangerous to those unfamiliar with a Bourne-like shell. Beware the commands you choose to query! In order to accept user determined commands into the summary list, commands could not be translated into their perl equivalents and so the commands are literally being entered into the shell. Again, this was intended to suplement the information provided by the great many utilities already used by many of you. Use this to "fill in the blanks" like "perl -V". If you do not like the options, just change them (at your own peril mwahaha). This is populated by the values I was needing at the time I wrote the first sloppy version. Use them as a starting point and add, remove, and rearrange as much as you want. I would be interested to know what other "uncommon" values the rest of you find yourselves needing yet frequently absent from other such summary utilities.

#!/usr/bin/perl -w
# bourne.pl "monkified" v1.0
# bart lines 5 & 29, and theorbtwo for ! delimiters line 36
use strict;
############
## note: six assumptions are made here...
## 1) $USER legal characters are alphanumeric, "_", or "-"
## 2) $USER is between 3 and 16 characters in length
## 3) your default shell is a bourne-like shell (like bash)
## 4) you know enough bourne shell to not get in trouble
## 5) your $HOME directory is /home/$USER
## 6) you accept that you are using this at your own risk
my @cmds = split /\n/, <<'--CMDs--';

############
##  edit

whoami
pwd
id
echo \$PATH=$PATH
echo \$PERL5LIB=$PERL5LIB
perl -V

############
## no edit

--CMDs--
my $i=4;
my $size=@cmds;
my $me=`whoami`;
my $dir=`pwd`;
$me=~s/\n//;
$dir=~s/\n//;
$dir=~s!\/home\/[\w-]{3,16}\/!\/!;
my $prompt="$me\@~$dir>";
print "Content-type: text/plain\n\n";
while ($i <= $size - 4) { my $cmd=$cmds[$i]; print $prompt,"$cmd\n",`$
+cmd`,"\n"; $i++; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://557617]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2021-01-24 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?