LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-27-2005, 09:26 AM   #1
crazygyhrous
LQ Newbie
 
Registered: Dec 2005
Posts: 13

Rep: Reputation: 0
Re-using IP address in Script possible?


Is there any way I can re-use an IP address for a shutdown script in a network? I want to got to each machine and compare the IP address with the one I'm running the script from. I would like to shutdown the mmachine running the script at last (dah!). I'm usign Expect for the script. Can anyone help me here?

#!/usr/bin/expect
spawn ssh@xxx.xxx.x.x
(if IP source != IP from script execute ssh
else exit)

expect"password:"
send"dummy\r"
expect"*#"

Thanks!!
 
Old 01-03-2006, 05:00 PM   #2
ak99505
Member
 
Registered: Feb 2005
Location: Missouri
Distribution: Archlinux
Posts: 85

Rep: Reputation: 17
this isn't pretty but i'm still learning awk and sed so this the best i could do.
Code:
ipsrc=`ifconfig eth0 | grep 'inet ' | awk -F":" '{print $2}' | awk '{print $1}'`
that will get you the ip address of the machine, like i said it's not pretty
I'm sure there is a better way, but I'm still learning awk and sed.
I think you can get the two awk pipes in to one call to awk but i'm not sure
since they are using two different dilimeters.

also could you be a little more clear on what you are trying to achieve here
why would you want to run a script to shut donw multiple machines, seems to
me like that could be trouble.
 
  


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 or cmd to retun my ip address.... Scrag Linux - Networking 5 07-05-2009 10:19 PM
Change IP address via script ricky_ds Red Hat 2 01-04-2005 10:34 AM
creating a script to ask for a new IP address stellarmarine1 Linux - General 5 09-12-2004 08:08 PM
Bash Script: Getting IP address fr0st Programming 3 01-14-2004 06:22 PM
Script to capture dynamic IP address scon Linux - General 4 02-21-2003 03:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:14 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