[SLE] shell script question.
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? Thanks Nick -- -------------------------------------------------- Nick Zentena "Microsoft has unjustifiably jeopardized the stability and security of the operating system." U.S. District Judge Thomas Penfield Jackson Nov 5/1999 -------------------------------------------------- -- 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 Wed, Dec 01, 1999 at 11:29:21AM -0500, Nick Zentena wrote: ...
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?
You may need to hard-code the path to ifconfig in the script. Depending on how you want to run the script, a "shebang" line might be useful, e.g., #!/bin/sh as the first line, then use, e.g., 'chmod g+x myscript' to make it executable. The fact that you can run ifconfig seems suspicious to me, since a normal (non-root) user probably shouldn't be running things in /sbin or /usr/sbin. Maybe you've got a symbolic link to ifconfig (which is ok). If you're running as root (not recommended!) another issue may be that root normally doesn't include the current directory in the path; in that case you'd have to use './myscript' to explicitly specify the path. -- Ken Irving Trident Software jkirving@mosquitonet.com -- 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 Wed, 1 Dec 1999, Ken Irving wrote: ki> On Wed, Dec 01, 1999 at 11:29:21AM -0500, Nick Zentena wrote: ki> ... ki> > Which won't work for some reason. I've managed to get: ki> > ki> > ifconfig ppp0 | grep 'addr' | awk '{printf $2}' | sed -e s/addr:// ki> > ki> > to work from the command line but I'm banging my head against the wall ki> > getting it to work from within a script. So anybody willing to point out ki> > the right way to do this? ki> ki> You may need to hard-code the path to ifconfig in the script. ki> ki> Depending on how you want to run the script, a "shebang" line might be ki> useful, e.g., ki> ki> #!/bin/sh ki> ki> as the first line, then use, e.g., 'chmod g+x myscript' to make it executable. ki> ki> The fact that you can run ifconfig seems suspicious to me, since a normal ki> (non-root) user probably shouldn't be running things in /sbin or /usr/sbin. ki> Maybe you've got a symbolic link to ifconfig (which is ok). ki> Correct, a normal user wouldn't see ifconfig in their path as ifconfig is typically a system command which is what its being used for in my previous post. By adding a line to ip-up that calls an external file with that line in it, your having the system run the ifconfig command, not the user. Typical example is with diald, wvdial, kpp, ezppp, etc.. all these will typically call ip-up and ip-down when a connection is initiated or closed. ki> If you're running as root (not recommended!) another issue may be that root ki> normally doesn't include the current directory in the path; in that case you'd ki> have to use './myscript' to explicitly specify the path. ki> ki> -- S.Toms - tomas@primenet.com - New homepage coming soon SuSE Linux v6.2+ - Kernel 2.2.13 In Lexington, Kentucky, it's illegal to carry an ice cream cone in your pocket. -- 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 Wed, 1 Dec 1999, Nick Zentena wrote: nz> nz> Okay I'm trying to set my IP into my firewall script automatically. I nz> took the info posted here awhile ago by S.Toms. nz> nz> EXT_INT="eth0" # whichever you use nz> IPADDR="`ifconfig ${EXT_INT} | grep 'inet addr' | awk '{print $2}' | sed nz> -e 's/. nz> That second line should actually read like the following, but all on one line (the mailer will make it two lines) IPADDR="`ifconfig ${EXT_INT} | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`/32" nz> Which won't work for some reason. I've managed to get: nz> nz> ifconfig ppp0 | grep 'addr' | awk '{printf $2}' | sed -e s/addr:// nz> nz> to work from the command line but I'm banging my head against the wall nz> getting it to work from within a script. So anybody willing to point out nz> the right way to do this? nz> And if your putting it within a script, don't forget the #!/bin/sh in the first line of the file. nz> Thanks nz> Nick nz> -- S.Toms - tomas@primenet.com - New homepage coming soon SuSE Linux v6.2+ - Kernel 2.2.13 Down with categorical imperative! -- 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 (3)
-
jkirving@mosquitonet.com
-
tomas@primenet.com
-
zentena@hophead.dyndns.org