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
grep ip address rein Shell Programming and Scripting 2 05-22-2009 01:25 AM
Grep Ip address wfleenor UNIX for Dummies Questions & Answers 6 03-07-2009 09:09 AM
Unix terminal re-assigned with wrong IP address from window's DHCP tlee SUN Solaris 0 03-11-2008 01:44 AM
How to Achive IP address through MAC(Ethernet) address krishnacins IP Networking 3 08-29-2005 08:45 PM
network address and broadcast address? pnxi UNIX for Dummies Questions & Answers 7 11-10-2003 11:29 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 03-27-2007
chongkls77 chongkls77 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 10
How to grep dhcp ip address

Hi,

I have a script that my operators use as a login profile.
As they need to export their display in order to access the GUI of the data protector program in HPUX machine.
Anyone can advise how I can grep (eg. who -r) the dynamically assigned IP address and automatically put it as a variable in my script. So whenever I login, the script will do a grep of my current IP add and do a replacement of the ip in the script as needed.

Thanks and best regards
Solomon
  #2 (permalink)  
Old 03-27-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,211
Once logged into the target machine:

Code:
who am i | sed 's/[^(]*(\([^)]*\))/\1/'
  #3 (permalink)  
Old 03-28-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,211
sorry on HPUX use who -R


Quote:
Originally Posted by reborg
Once logged into the target machine:

Code:
who am i | sed 's/[^(]*(\([^)]*\))/\1/'
  #4 (permalink)  
Old 03-28-2007
chongkls77 chongkls77 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 10
hmm, who am i does not show the user IP address.

presently in the script the display set is hard coded:

DISPLAY=XX.X.XX.XX:0.0
export DISPLAY

how to make the dhcp assigned user IP address update dynamically?
  #5 (permalink)  
Old 03-28-2007
strobotta strobotta is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 10
try
Code:
hostname --ip-address
At least this works for a fixed IP address on a Linux box.

on a FreeBSD box you can also try
Code:
ifconfig
There you still have to parse output according to your needs.
Closed Thread

Bookmarks

Tags
export display

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:45 AM.


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