View Single Post
Old 09-01-2011, 01:16 PM   #40
pconwell
Junior Member
pconwell began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Dec 2010
Device: kindle 3
Kranu,

I made some slight modifications to your script. Nothing major, just makes it a little easier to see how to get the kindle to connect.

http://pastebin.com/Q6ipRm78

----

Here is a "better" way to get the ip, but I can't get the white space out between the IP and the port. If I can figure out a way to get rid of the white space, I'll post it up on pastebin again. And yes, I'm sure there is a much cleaner way to do this, but I'm not *that* familiar with awk. Anyway, you can see what I'm getting at:

Code:
  os.system("/sbin/ifconfig | grep inet | grep -v inet6 | grep -v 127 | awk '{ sub(/inet addr:/, \"\"); print }' | awk '{ sub(/Bcast:.............../, \"\"); print }' | awk '{ sub(/M................./, \"\"); print }' | awk '{print $0,\":8000\"}'")
Ha, nevermind, I figured it out. Here is the 'correct' (if not very clean) way to do it:

Code:
  os.system("/sbin/ifconfig | grep inet | grep -v inet6 | grep -v 127 | awk '{ sub(/inet addr:/, \"\"); print }' | awk '{ sub(/Bcast:.............../, \"\"); print }' | awk '{ sub(/M................./, \"\"); print }' | awk '{print $1,\":8000\"}' |awk '{ sub(/ /, \"\"); print }'")
... and here is the pastebin: http://pastebin.com/2zTgPLFA

Last edited by pconwell; 09-01-2011 at 02:05 PM.
pconwell is offline   Reply With Quote