Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 28 Jul 2014, 14:46
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
How to get IP address of PC?(Solved)
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [11 Posts]  
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 5010
Location: Arizona, U.S.A.

PostPosted: Wed 23 Nov 2005, 19:51    Post subject:  How to get IP address of PC?(Solved)  

I typed: env to get environment variables & I saw nothing that looked like an IP, ifconfig shows: 192.168.0.100
How do I get the assigned IP for the PC into an environment variable to use in Puppy startup scripts?
I assume Puppy is getting the IP from my router or dhcp-pxe boot server.
Back to top
View user's profile Send private message 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Wed 23 Nov 2005, 19:56    Post subject:  

Add this line to one of the startupscripts:

MYIP=`ifconfig |grep "P-t-P"| sed "s/^.*addr://" | sed "s/\w.*//"`
export $MYIP

You can test it with
echo $MYIP >/tmp/iptest.txt

When puppy started, that file should contain your ip.
This is the IP you get assigned by your hoster using an internet-connection.
For the other ones, you might have to modify the command.

If you get stuck, please post the whole line you get with ifconfig, then we might help.

Mark
Back to top
View user's profile Send private message Visit poster's website 
GuestToo
Puppy Master

Joined: 04 May 2005
Posts: 4078

PostPosted: Wed 23 Nov 2005, 21:08    Post subject:  

Code:
IPADR=`wget http://ipid.shat.net/iponly/ -O /dev/stdout | head -n 3 | tail -n 1`

echo $IPADR
Back to top
View user's profile Send private message 
Guest
Guest


PostPosted: Wed 23 Nov 2005, 21:12    Post subject:  

I typed in the line just as you showed it, then the export line says: "not a valid identifier" on all the "|" pipes & the 3 "" statements.
Weard there isn't already a vari. for this, guess nothing needs it.

eth0 Link encap:Ethernet HWaddr 00:50:DA:71:1F:C8
inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10381 errors:0 dropped:0 overruns:1 frame:0
TX packets:530 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3471943 (3.3 MiB) TX bytes:68737 (67.1 kiB)
Interrupt:11 Base address:0xe800

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 iB) TX bytes:0 (0.0 iB)
Back to top
GuestToo
Puppy Master

Joined: 04 May 2005
Posts: 4078

PostPosted: Wed 23 Nov 2005, 21:13    Post subject:  

or
Code:
IPADR=`wget -q "http://ipid.shat.net/iponly" -O - | sed -n 3p`

echo $IPADR
Back to top
View user's profile Send private message 
GuestToo
Puppy Master

Joined: 04 May 2005
Posts: 4078

PostPosted: Wed 23 Nov 2005, 21:15    Post subject:  

you can copy from the forum page by selecting the text with the mouse ... then paste in a rxvt console by clicking the middle mouse button
Back to top
View user's profile Send private message 
GuestToo
Puppy Master

Joined: 04 May 2005
Posts: 4078

PostPosted: Wed 23 Nov 2005, 21:19    Post subject:  

your local address is 192.168.0.100
to see your external address, click http://ipid.shat.net/iponly/
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5010
Location: Arizona, U.S.A.

PostPosted: Wed 23 Nov 2005, 21:26    Post subject:  

Sorry, I used ' instead of `, exports output is a list of the env vari.s saying: declare -x (vari. & it's value), echo returns nothing.
GuestToo; yours works, but I need the PCs net IP, not the web IP of my router.
I need to put IP in a env variable for boot script so many clients have Samba mount point for separate HOME automatically.
Example: smbmount //$IP_SRV/LanPup/$IP_CLI /mnt/home
Back to top
View user's profile Send private message 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Wed 23 Nov 2005, 22:36    Post subject:  

MYIP=`ifconfig |grep "Bcast"| sed "s/^.*addr://" | sed "s/\w.*//"`
export MYIP

This does:
run ifconfig
pipe (|) the result to grep
grep looks for the line with "Bcast"
So we have
inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0

Next it is piped to sed, that filters everything from the beginning (^) to addr:
So we have
192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0
Then again pipe through sed, filter the first whitespace (\w) and all after it (.*)
So we have
192.168.0.100

export MYIP might not be needed.
But on some system it assures, the variable is available in subshells, too.
(export $MYIP was wrong, don't use the $)

Mark

Last edited by MU on Wed 23 Nov 2005, 22:51; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
sunburnt


Joined: 08 Jun 2005
Posts: 5010
Location: Arizona, U.S.A.

PostPosted: Wed 23 Nov 2005, 22:46    Post subject:  

THANKS MU!!! It works great! Above you had: export $MYIP, I wondered about that, but wasn't sure.
I got smbmount working so I think this is all coming together.
Thanks again, hope I can call on you again in the future.
Back to top
View user's profile Send private message 
Rhino


Joined: 04 May 2005
Posts: 262
Location: Cincinnati, OH, USA

PostPosted: Wed 23 Nov 2005, 23:33    Post subject:  

A very simple method is to open Dillo and click the bookmark icon and then go to "What is my IP"

On second though, that may be more complicated than the command line stuff Smile
Back to top
View user's profile Send private message Yahoo Messenger 
Display posts from previous:   Sort by:   
Page 1 of 1 [11 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0594s ][ Queries: 12 (0.0043s) ][ GZIP on ]