Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking Network Access

Status
Not open for further replies.

MrsKensington

Programmer
Sep 26, 2001
28
GB
As BT keep on cutting off our ADSL unexpectedly i've decided to write a perl script to show the state of e-mail, internet and internal network access, so people in other departments can check if there are any errors before phoning technical support.
I have an idea on checking the Internal Network and internet access. They both involve copying a file and timing how long it takes and from there deciding if it is running fine, slow or not at all.
For the local network i'm copying a 1Mb file off one of our servers and for the internet access i'm copying a 100K file off demons FTP site (it's a test file so it'll always be there).

I have this at the top of my page
use File::Copy;
$localFile = "\\\\amy\\Shr_Docs2\\doNotDelete";

my current code is
Code:
#get start time
$startTime = getCurrentTime();
#do job
getSpeedOfLocalNetwork($localFile);
#get end time
$endTime = getCurrentTime();
#get time difference
print getTimeTaken($startTime, $endTime);

where getSpeedOfLocalNetwork() is...
Code:
sub getSpeedOfLocalNetwork()
{
	my ($file) = @_;
	my $toReturn = -1;  
	if (copy($file, "c:\emptyFile"))
	{
		$toReturn = 1;
	}
	else
	{
		$toReturn = 0;
	}	
	return $toReturn;
}

for some reason it always returns 0! What am I doing wrong?

Is there a better way of testing/timing it?

Thanks alot for your help

p.s. oh and I definately got the path correct Ford? There's an infinite number of monkeys outside wanting to talk to you about a script of Hamlet they've produced!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top