[opensuse-factory] ipconfig didn't works when called from zypper
Hi to all, Any ideas why a command like ifconfig works when invoked from a %post hook when package is installed via rpm -Uvh but not when same package is installed via zypper from an external repository ? %post IP_LOC=`/sbin/ifconfig | grep "inet adr" | grep -v 127.0.0.1 | awk -F: '{print $2}' | awk '{print $1}' | awk -F. '{print $1"."$2}'` echo $IP_LOC It will return blank if package is installed from zypper (zypper install) and your 2 first digits if installed via rpm -Uvh Thanks for your help / advices -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
On 07/17/2012 02:49 PM, Henri Gomez wrote:
Hi to all,
Any ideas why a command like ifconfig works when invoked from a %post hook when package is installed via rpm -Uvh but not when same package is installed via zypper from an external repository ?
%post
IP_LOC=`/sbin/ifconfig | grep "inet adr" | grep -v 127.0.0.1 | awk -F: '{print $2}' | awk '{print $1}' | awk -F. '{print $1"."$2}'` echo $IP_LOC
It will return blank if package is installed from zypper (zypper install) and your 2 first digits if installed via rpm -Uvh
If I execute the above command as normal user, IP_LOC is empty as well. Change spelling "inet adr" like "inet addr", does that help? Strange that it worked in one case - perhaps you have in one case LANG set and not in the other? Just compare: LANG=C IP_LOC=`/sbin/ifconfig | grep "inet addr" | grep -v 127.0.0.1 | awk -F: '{print $2}' | awk '{print $1}' | awk -F. '{print $1"."$2}'`;echo $IP_LOC 192.168 10.123 192.168 aj@linux-6dv9:~/Software/vcs/glibc> LANG=de_DE.UTF-8 IP_LOC=`/sbin/ifconfig | grep "inet addr" | grep -v 127.0.0.1 | awk -F: '{print $2}' | awk '{print $1}' | awk -F. '{print $1"."$2}'`;echo $IP_LOC So, I suggest to add LANG=C, Andreas -- Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg) GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
On 17 July 2012 13:49, Henri Gomez <henri.gomez@gmail.com> wrote:
Hi to all,
Any ideas why a command like ifconfig works when invoked from a %post hook when package is installed via rpm -Uvh but not when same package is installed via zypper from an external repository ?
%post
IP_LOC=`/sbin/ifconfig | grep "inet adr" | grep -v 127.0.0.1 | awk -F: '{print $2}' | awk '{print $1}' | awk -F. '{print $1"."$2}'` echo $IP_LOC
It will return blank if package is installed from zypper (zypper install) and your 2 first digits if installed via rpm -Uvh
Thanks for your help / advices
Why are you doing such a thing? What do you expect to happen if there are multiple interfaces? What if no interface has a IPv4 address? address is written with two 'd'. If there are any further differences probably are because one of them sets the locale to C. -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
Why are you doing such a thing? What do you expect to happen if there are multiple interfaces? What if no interface has a IPv4 address?
address is written with two 'd'.
If there are any further differences probably are because one of them sets the locale to C.
For an in-house package for our infra-structure, I try to determine site location from ip. Each site has its own x.y IP -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
BTW, Andreas was correct, problem was related to LANG. Thanks for it ! :) 2012/7/17 Henri Gomez <henri.gomez@gmail.com>:
Why are you doing such a thing? What do you expect to happen if there are multiple interfaces? What if no interface has a IPv4 address?
address is written with two 'd'.
If there are any further differences probably are because one of them sets the locale to C.
For an in-house package for our infra-structure, I try to determine site location from ip. Each site has its own x.y IP -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
participants (3)
-
Andreas Jaeger
-
Cristian Morales Vega
-
Henri Gomez