LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-14-2011, 06:51 PM   #1
ericasass
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Rep: Reputation: Disabled
Ping IP addresses using bash and linux


Im new to linux and am trying to write a script that will ping IP addresses and say either online or unavailable...Any help would be great!!!! Thanks
 
Old 06-14-2011, 07:18 PM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Code:
ping -c 1 $1
if [ "$?" -ne "0" ]; then
echo Not available
exit 1
fi
echo Online
Untested.

Last edited by smeezekitty; 06-14-2011 at 07:21 PM.
 
Old 06-14-2011, 08:31 PM   #3
ericasass
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thnanks for the help!!!!!
 
Old 06-14-2011, 10:31 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Please mark as SOLVED once you have a solution.
 
  


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
Script to ping multiple IP addresses one by one peddip Linux - Server 14 09-15-2011 11:44 PM
Cannot ping virtual ip addresses (VIP) mixxalot Linux - Networking 3 11-25-2007 01:50 PM
Unable to ping web addresses, but able to resolve them? boyd98 Linux - Networking 3 03-27-2005 02:37 PM
ping and IP addresses BACTRATE Mandriva 3 06-16-2004 06:49 PM
Can't ftp/ping external addresses from client corrierich Linux - Networking 6 04-15-2003 12:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:04 AM.

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