List Info

Thread: gnuwin32




gnuwin32
user name
2006-10-14 12:05:10
Hi,

 Intro:

 I don't script a lot mainly because at work we're forced
into the
 windows 2003, AD and XP mould which means putting up with
the 'quirky'
 windows command shell (yes, quirky is a euphemism - I'll
let you
decide
 what for).

 Prob:

 I've used xargs in past to pass piped command output into a
subsequent
 command that doesn't normally accept parameters from the
pipe (in
 debian linux)

 e.g.    command1 | xargs command2 *output from command 1*

 I wanted to set a variable to the output of a string of
commands and
as
 windows shell won't allow
 set variable=`commands` I thought I'd use xargs as below.

 /CODE/

 >ping -n 1 whrcsdp05922 | awk "/TTL/ {print
$3}" | awk -F: "{print
$1}" | xargs --verbose set pcip=

 /ENDCODE/

 The result is:

 set pcip= 10.60.1.77
 xargs: set: No such file or directory

 ok, I've run the above output (set pcip= 10.60.1.77) on the
command
 line on its own and the variable is set.

 I'll work another solution out somehow, if not with xargs,
but I'd
kind
 of like to understand what the problem is (actually
understand not
just
 go - oh it's that quirky windows command shell).
 
 Thanks for any help and please excuse the long explanation.
 
 Steve

_______________________________________________
help-gnu-utils mailing list
help-gnu-utilsgnu.org

http://lists.gnu.org/mailman/listinfo/help-gnu-utils
gnuwin32
user name
2006-10-14 23:59:25
"Steve" <steve.mayesgmail.com> wrote:
>  /CODE/
>
>  >ping -n 1 whrcsdp05922 | awk "/TTL/ {print
$3}" | awk -F: "{print
> $1}" | xargs --verbose set pcip=
>
>  /ENDCODE/
>
>  The result is:
>
>  set pcip= 10.60.1.77
>  xargs: set: No such file or directory

set is a command shell builtin, and xargs can only run
external
commands.  Something like this might work:

ping -n 1 whrcsdp05922 |
awk "/TTL/ {print $3}" |
awk -F: "{print "set pcip=" $1}" |
cmd

Of course, the variable will be set only in that invocation
of cmd, so
whatever depends on the variable should probably be included
in the
commands written by the second awk.


paul


_______________________________________________
help-gnu-utils mailing list
help-gnu-utilsgnu.org

http://lists.gnu.org/mailman/listinfo/help-gnu-utils
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )