For Programmers: Free Programming Magazines  


Home > Archive > AWK > October 2006 > gawk: strange xargs behaviour in XP









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author gawk: strange xargs behaviour in XP
Steve

2006-10-14, 3:55 am

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

Steve

2006-10-18, 3:56 am


Manuel Collado wrote:
> Steve escribi=F3:
| xargs --verbose set pcip=3D[color=darkred]
>
> The problem has nothing to do with gawk. You are telling xargs to invoke
> the 'set' command. But this is not an executable file (so the error
> message). 'set' is a built-in command, and could be executed by invoking =

an
> explicit command processor:
>
> ... | xargs cmd.exe /c set ...
>
> Regretably, this form of 'set' doesn't have any effect in the primary she=

ll
> that executes xargs, but only in the secondary shell. Its effect is lost =

as
> soon as the secondary shell terminates.
>
> BTW, there are sh/bash Windows ports. At least you can choose among DJGPP,
> Cygwin and MinGW/Msys. They implement the `command` substitution feature.
>
> Hope this helps.
> --
> Manuel Collado


Manuel

Yes that does help, and explain, and thanks for the response even
though I posted in the wrong group.

steve

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com