eval exec "ifconfig | grep $eth_if | awk \'{print $1}\'"
--C. Ulrich
Instead of using awk, try to use the command output:
set values {}
set out [eval exec "ifconfig | grep $eth_if"]
foreach line [split $out \n] {
lappend values [lindex $line 0]
}
Giovanni
Use a backslash before $1 as well. The braces { } loose their
special meaning inside "" (or that is what I have noticed):
eval exec "ifconfig | grep $eth_if | awk \'{print \$1}\'"
Regards,
Arjen
Then again, a simple grep can also be handled by Tcl built-in:
foreach line [split [exec ifconfig] \n] {
if {[regexp $eth_if $line]} {lappend values [lindex $line 0]}
}
--
Best regards, Richard Suchenwirth
(And I should probably quit trying to use external commands for stuff
that Tcl can do... :P)
--C. Ulrich
And (as the good folks in comp.unix.shell would point out) you can do
without the grep process:
eval exec "ifconfig | awk \'/$eth_if/ {print \$1}\'"
--
Kevin Rodgers <kev...@ihs.com>
And as this denizen of comp.lang.tcl will point out, you don't need the awk
either:
set f [open "|ifconfig" "r"]
while {[gets $f line] >= 0} {
if {[string match $eth_if $line] > 0} {
puts [lindex $line 0]
}
}
close $f
Note that this code was typed straight into the newsreader without benefit
of a tclsh or a unix box, and thus is worth almost as much as the paper it
is printed on.
Dan "Disk Lamer" Smart
--
Dan Smart. C++ Programming and Mentoring.
cpp...@dansmart.com
ADDvantaged
Surely that'd be [regexp $eth_if $line] or [string first $eth_if $line]?
> puts [lindex $line 0]
Is ifconfig output regular enough to do that, or is a [split] needed?
> }
> }
> close $f
Donal.
--
Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fell...@cs.man.ac.uk
make: *** No rule to make target `war'. Stop.
Dan "Excuse me, do you have a light, I've run out of firsts" Smart