Re: [SLE] shell script question.
Nick Zentena <zentena@hophead.dyndns.org> writes:
Okay I'm trying to set my IP into my firewall script automatically. I took the info posted here awhile ago by S.Toms.
EXT_INT="eth0" # whichever you use IPADDR="`ifconfig ${EXT_INT} | grep 'inet addr' | awk '{print $2}' | sed -e 's/.
Which won't work for some reason. I've managed to get:
ifconfig ppp0 | grep 'addr' | awk '{printf $2}' | sed -e s/addr://
to work from the command line but I'm banging my head against the wall getting it to work from within a script. So anybody willing to point out the right way to do this?
Or ... if you prefer to not use perl: export IPADDR=$(ifconfig ${EXT_INT}|sed -ne '/addr:/{s/.*addr:\([^ ]*\).*/\1/;p;}') Hope this (or the perl version) helps. (TIAAWTDI) (Leaving out the export is probably what was causing you problems, but cutting 3 processes down to 1 is always a big savings. -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
On 1 Dec 1999, Mark Gray wrote: mg> Nick Zentena <zentena@hophead.dyndns.org> writes: mg> mg> > to work from the command line but I'm banging my head against the wall mg> > getting it to work from within a script. So anybody willing to point out mg> > the right way to do this? mg> mg> Or ... if you prefer to not use perl: mg> mg> export IPADDR=$(ifconfig ${EXT_INT}|sed -ne '/addr:/{s/.*addr:\([^ ]*\).*/\1/;p;}') mg> mg> mg> Hope this (or the perl version) helps. mg> (TIAAWTDI) mg> mg> (Leaving out the export is probably what was causing you problems, but mg> cutting 3 processes down to 1 is always a big savings. mg> The only real purpose of export is to make it available to the rest of the system, in the case of initializing a firewall, or making the ip available for a script that is run from within the same file as the ipaddr query, an export isn't really necessary. Whether making that a global variable will interfere somehow down the road I don't know, but if it doesn't have to be global, why take the chance? Does that make sense? mg> mg> -- S.Toms - tomas@primenet.com - New homepage coming soon SuSE Linux v6.2+ - Kernel 2.2.13 "The voters have spoken, the bastards ..." -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
participants (2)
-
markgray@iago.nac.net
-
tomas@primenet.com