Created
October 9, 2014 20:22
-
-
Save chrisice/78c0911fa90ee657745b to your computer and use it in GitHub Desktop.
Get document root
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
my $input = $ARGV[0]; | |
if ($input !~ /.*@.*/) { | |
print "Please enter a valid email address.\n"; | |
die("\n"); | |
} | |
else{ | |
($user, $domain) = $ARGV[0] =~ /(.*)@(.*)/; | |
my %used; | |
my $string = 'grep -3'; | |
my $domainstring = "www.$domain"; | |
my $lookupfile = '/usr/local/apache/conf/httpd.conf'; | |
@lines = qx/$string $domainstring $lookupfile/; | |
@stuff = grep( /.*$domianstring.*/, @lines); | |
@stuff = grep(/^.+?(\/.+\/.+$)/, @stuff); | |
$numlines = scalar(grep {defined $_} @stuff); | |
if ( $numlines != 1 ) { | |
pop @stuff; | |
foreach $stuff (@stuff) { | |
print $1 if $stuff =~ m/(\/.*$)/; | |
print "\n"; | |
} | |
} | |
else { | |
foreach (@stuff) { | |
print $_; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment