LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-07-2011, 04:14 AM   #1
dawood munavar
LQ Newbie
 
Registered: Apr 2011
Posts: 1

Rep: Reputation: 0
#In this perl code, im getting the input as "ip address" from the user and pinging it


#To check the servers can able to ping or not

#!/usr/bin/perl


use Net::Ping;

$p=Net::Ping->new();



print " ENTER THE NUMBER OF SERVERS \n";

my $servers=<STDIN>;

for($i=1; $i<=$servers; $i++)

{


print "ENTER THE SERVER $i IP ADDRESS \n";

$i[a]=<STDIN>;



}





for($i=1; $i<=$servers; $i++)
{

if($i[a]=~ /\d+.\d+.\d+.\d+/)

{


if($p->ping("$i[a]"))

{


print "\n PING IS SUCESSSSSS!!!! \n";

print "$i[a] \n";

}
else
{


print "\n \a REQ TIMED OUT \n";

print "$i[a] \n";

}
}


}
#In this perl code, im getting the input as "ip address" from the user and pinging it. when i compile and run this code, say when i get 3 ipaddress from the user only my 3rd ip is pinging, the 1st 2 "ipaddress" are not pinging. So could you please tell me what is the error?
 
Old 04-07-2011, 09:42 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Hi, welcome to LQ!


I recommend changing the first line of your script to say
Code:
#!/usr/bin/perl -w
and add

Code:
use strict;
right underneath it ...

And then fix the warnings (which should eliminate logic errors
to some extent).


Cheers,
Tink
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Accepting single backslash "\" as a user input. sundar_r05 Linux - Enterprise 6 02-02-2010 05:29 AM
"Not a CODE" reference error perl v5.10.0, Deprecated assignment operation. skuletm Programming 3 03-12-2009 12:21 AM
please help me with this perl code getting error "use of uninitialized value" haxpak Programming 10 03-01-2009 10:55 PM
Repeated "input: AT Translated Set 2 keyboard as /class/input/input" messages AcerKev Mandriva 2 09-16-2007 08:35 AM
PHP doesn't "remember" the user input. What to do? linuxfond Programming 10 09-04-2003 07:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration