Capturing IP address


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capturing IP address
# 1  
Old 04-06-2010
Capturing IP address

I'm trying my first shell script. I would like my computer to launch an application if I'm on my work network, or mount my shared files if I'm on my home network. Here's how I'm trying to do it...

Code:
#!/bin/bash

CURRENT_IP=ipconfig getifaddr en1
HOME=192.168.1.6
WORK=192.168.0.123

if [ "$CURRENT_IP"=="$WORK" ]; then
	# launch Adium
	open -a "/Applications/Adium.app"
else if [ "$CURRENT_IP"=="$HOME" ]; then
	# mount shared folders
	mount -t smbfs //[username]:[password]@[server]/Music /Volumes/Music
	mount -t smbfs //[username]:[password]@[server]/Backup /Volumes/Backup
fi

exit 0

Evidently the way I'm trying to capture the current IP address isn't correct? I'm also getting and "unexpected end of file" error, but first things first Smilie

---------- Post updated at 03:08 PM ---------- Previous update was at 03:04 PM ----------

BTW, i should probably note I'm running on OS X 10.6.3 Snow Leopard and my shared files are on a Buffalo LinkStation Pro
# 2  
Old 04-06-2010
Code:
#!/bin/bash

CURRENT_IP=$(ipconfig getifaddr en1)

# 3  
Old 04-06-2010
Quote:
Originally Posted by vgersh99
Code:
#!/bin/bash

CURRENT_IP=$(ipconfig getifaddr en1)

wow, that was fast Smilie It worked, thank you!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

IP address not capturing in autil trails

Hi, I have AIX 6.1 server. unfortunately IP address of client is not capturing when logged with SSH, where as it is showing when logged with Telnet. Any configuration required in /etc/security/audit/events to capture IP address (SSH) ? (0 Replies)
Discussion started by: suresh3566
0 Replies

2. UNIX for Advanced & Expert Users

C program to detect duplicate ip address if any after assigning ip address to ethernet interface

Hi , Could someone let me know how to detect duplicate ip address after assigning ip address to ethernet interface using c program (3 Replies)
Discussion started by: Gopi Krishna P
3 Replies

3. IP Networking

Tracing a MAC address to IP address: Solaris

Hi there I lost connectivity to one of our remote systems and when I checked the messages log I found the following: Aug 10 23:42:34 host xntpd: time reset (step) 1.681729 s Aug 16 13:20:51 host ip: WARNING: node "mac address" is using our IP address x.x.x.x on aggr1 Aug 16 13:20:51 host... (9 Replies)
Discussion started by: notreallyhere
9 Replies

4. UNIX for Dummies Questions & Answers

What would the physical address be for virtual address?

Hi guys, I got one problem which I definetily no idea. What would the physical address be for virtual address? 1) 2ABC 2) 3F4B Here is the page table:see attached Thank you sos sososososso much!! (0 Replies)
Discussion started by: lemon_06
0 Replies

5. UNIX for Dummies Questions & Answers

Panic kernal-mode address fault on user address 0x14

:) Firstly Hi all!!, im NEW!! and on here hoping that someone might be able to offer me some help... i have a server that keeps crashing every few days with the error message: PANIC KERNAL-MODE ADDRESS FAULT ON USER ADDRESS 0X14 KERNAL PAGE FAULT FROM (CS:EIP)=(100:EF71B5BD) EAX=EF822000... (10 Replies)
Discussion started by: Twix
10 Replies

6. Shell Programming and Scripting

ksh - how to list all ip address between 2 ip address

Trying to do a ksh script that needs to list all ip address between ip address a and b .. ie. Ip address A=192.168.1.200 Ip address B=192.168.2.15 So the subnet changes from 1 to 2 but I want to list all possible ip addresses between the 2.. Which would be: 192.168.1.200... (4 Replies)
Discussion started by: frustrated1
4 Replies

7. UNIX for Dummies Questions & Answers

Capturing a value in to variable.

Hi, I currently have a shell script where it captures in the value in to 'TOTAL' and outputs to a file, i want to capture another value of a query in to another variable and output it. Current script: sqlplus -s $user <<EOD | read TOTAL set heading off set pages 0 set feedback off set... (1 Reply)
Discussion started by: ravi0435
1 Replies

8. Shell Programming and Scripting

capturing the o/p to a variable

Hi, #Script mentioned below txt=($(echo `./demo1.sh`)) p=0 for p in "$txt" do col=($(./generateTable /import/data01/sri/Developer/SqlReport/Lab/23/${var} "$p")) . . . . done o/p displayed upon executing a script called "demo1.sh" is as below(two seperate lines):... (2 Replies)
Discussion started by: villain41
2 Replies

9. IP Networking

How to Achive IP address through MAC(Ethernet) address

Hi sir, i want to make such programe which takes MAC(Ethernet) address of any host & give me its IP address....... but i'm nt getting that how i can pass the MAC address to Frame........ Please give me an idea for making such program... Thanks & regards Krishna (3 Replies)
Discussion started by: krishnacins
3 Replies

10. UNIX for Dummies Questions & Answers

network address and broadcast address?

say I have a IP address which is 10.0.0.12, and subnet mask is 255.255.255.240, what is the network address and what is the broadcast address which host lives on? And could you explain how to get the answer? thanx in advance! (7 Replies)
Discussion started by: pnxi
7 Replies
Login or Register to Ask a Question