The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
quick script C shell ajp7701 Shell Programming and Scripting 1 03-18-2008 04:31 PM
Basic Shell script syntax help vignesh53 Shell Programming and Scripting 2 02-05-2008 10:14 AM
Quick help needed in the Shell Script namishtiwari Shell Programming and Scripting 1 02-01-2008 09:44 AM
basic c-shell help ayalex Shell Programming and Scripting 0 01-31-2006 10:22 PM
Need quick help with basic FIND in korn shell Freakytah Shell Programming and Scripting 6 11-30-2001 04:38 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-22-2007
eb222 eb222 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 6
need a quick basic shell script help

im trying to run the below if command

ifconfig -a |grep 10.100.120.21

gives me below output
inet addr:10.100.120.21 Bcast:10.100.120.255 Mask:255.255.255.0

i just want a basic shell which says if above exists then continue

how would i do this?
  #2 (permalink)  
Old 11-22-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Code:
#!/bin/sh

ifconfig -a |grep 10.100.120.21 
if test "$?" = "0"
then
     echo I found the address
else
     echo I did not find the address
fi
  #3 (permalink)  
Old 11-22-2007
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 500
Hi Porter,
What OS is ` ifconfig -a ` used in, doesn't work for HP-UX.
  #4 (permalink)  
Old 11-22-2007
eb222 eb222 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 6
thanks that worked -ifconfig -a is used to find ethernet addresses
  #5 (permalink)  
Old 11-22-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by Cameron View Post
Hi Porter,
What OS is ` ifconfig -a ` used in, doesn't work for HP-UX.
Solaris, NetBSD, Linux ... it's fairly common. It does the command for all interfaces.
  #6 (permalink)  
Old 11-22-2007
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 500
Cheers porter.
Thought I was missing something there for a moment.
  #7 (permalink)  
Old 11-22-2007
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Code:
[[ ! -z "$(ifconfig -a | grep 10.100.120.21)" ]] && echo Exists
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0