Depend on console-tools; drop runit
[grml-scripts.git] / usr_bin / myip
1 #!/bin/zsh
2 # Filename:      myip
3 # Purpose:       return IP address of running system on stdout (requires network access)
4 # Authors:       grml-team (grml.org), (c) Alexander Wirt <formorer@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Mon Aug 07 23:39:32 CEST 2006 [mika]
8 ################################################################################
9
10 # little helper functions that skips the httpheader of a site
11 function skip_httpheader {
12    for i in {1..7} ; do
13           read -u $REPLY LINE; 
14           if [[ "$LINE" == "\r" ]] ; then return ; fi
15   done
16 }
17
18 zmodload zsh/net/tcp
19 HOST=v4.showip.spamt.net
20 ztcp $HOST 80
21 print -u $REPLY "GET / HTTP/1.0\r\nHost: $HOST\r\n\r\n"
22 skip_httpheader
23 read -u $REPLY LINE
24 echo "$LINE"
25 ztcp -c $REPLY
26
27 ## END OF FILE #################################################################