|
|
Subject:
Bash Script for Debian Linux
Category: Computers > Programming Asked by: agkerr-ga List Price: $20.00 |
Posted:
20 Apr 2006 20:51 PDT
Expires: 20 May 2006 20:51 PDT Question ID: 721180 |
I would like a bash script for Debian Linux that executes a simple if/then relationship based on the machine's IP address, such as: If the machine's ip address is 192.168.1.200, then run "program command line, option a" There are 7-10 machines/ip addresses |
|
There is no answer at this time. |
|
Subject:
Re: Bash Script for Debian Linux
From: mootothemax-ga on 21 Apr 2006 09:17 PDT |
Would something like this do the job? ifconfig lists interfaces set up on the machine, along with their ip addresses. Here I'm just looping through all interfaces and checking what ip addresses are assigned. #!/bin/sh for foo in $(/sbin/ifconfig | grep "inet addr:" | sed -e 's/addr://g' | awk '{print $2}'); do if [[ $foo = "127.0.0.1" ]]; then //enter command to run elif [[ $foo = "127.0.0.2" ]]; then //enter another command fi done |
Subject:
Re: Bash Script for Debian Linux
From: mootothemax-ga on 21 Apr 2006 09:18 PDT |
Argh, formatting - the for foo in [...] | awk... bit should all be on one line, next line should begin if [[$foo ... |
Subject:
Re: Bash Script for Debian Linux
From: agkerr-ga on 21 Apr 2006 20:08 PDT |
This looks promising - I'll give it a spin on Monday and let you know |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |