How to get IP address in a single command in c and linux

In Linux,

                ifconfig $IFACE | awk '/inet addr:/ {split ($2,A,\":\"); print A[2]}' | awk 'NR==1{print $1}' > /tmp/LocalIP

 

In C,

                system("ifconfig $IFACE | awk '/inet addr:/ {split ($2,A,\":\"); print A[2]}' | awk 'NR==1{print $1}' > /tmp/LocalIP");

 

 

With Thanks & Regards,

Rajesh S

 

Comments

Popular Posts