Tiny Core Linux
Tiny Core Extensions => TCE Q&A Forum => Topic started by: wolf_core on June 21, 2012, 05:01:24 AM
-
Hi, I have a script that use netstat to get a value ad assign it to the variable "IP".
IP=`netstat -n -t | awk '{print $4}' | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -v "127.0.0.1" | sort -u`
I have installed net-tools to get netstat working but if I type in console netstat -n -t
no value returned because
tc@box:~$ netstat -n -t
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tc@box:~$
The network connection works fine, but no ip addres is shown. Can you help me.
Thanks in advance Luca
-
Neither clear in what aspect there would be a netstat problem nor how this would be related to TC Base...
What happens if you use 'busybox netstat' instead?
what does 'ifconfig |grep inet' give?
-
Ty tinypoodle, the system say
tc@box:~$ busybox netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
netstat:/proc/net/tcp6: no such file or directory
tc@box:~$ ifconfig |grep inet
inet addr:192.168.1.144 Bcast:192.168.1.255 Mask:255.255.255.0
inet addr:127.0.0.1 Mask:255.0.0.0
tc@box:~$
-
Well, empty output is expected if you have no connections open. If you need the local IP without opening a connection somewhere you should use ifconfig or ip.
-
Well, empty output is expected if you have no connections open. If you need the local IP without opening a connection somewhere you should use ifconfig or ip.
QED ;)
-
I have launched netstat command while the system download same packages form repository but non ip is shown :'( . How i can open a temporary connection to obtain the IP from nestat command. The php script use this IP to compose a session password used in some page as security system.
Thanks Luca
-
Hi wolf_core
If you SSH into another machine or mount a remote drive, that will do it. Or you could change:
[P=`netstat -n -t | awk '{print $4}' | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -v "127.0.0.1" | sort -u`
to:
IP=`ifconfig | awk '{print $2}' | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"`
-
Thanks Rich ;D the code you have posted put correct IP in the variable.
IP=`ifconfig | awk '{print $2}' | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -v "127.0.0.1"`
.
Thanks again for your help
-
Hi wolf_core
You are welcome. Bear in mind, if this script actually expects to find an open connection because the IP variable
is set, it could fail elsewhere. You didn't mention where the script came from or what it does, so I though I should
point that out.
-
Hi Rich, the script is 123Aurora a WEB solar logger, it is made to work with PogoPlug running ArchLinux but I try to use it on my DT166 Microserver running Tiny Core.
I think that there is another problem somewhere because i can't login, but now I can see the login page, so I return to the old code P=`netstat -n -t | awk '{print $4}' | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -v "127.0.0.1" | sort -u`
ad use cherokee for opening temp connections so netstat -n -t show some values.
Thanks Luca