Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!mouse From: mouse@thunder.mcrcim.mcgill.edu (der Mouse) Newsgroups: comp.unix.questions Subject: Re: Why doesn't this work? Keywords: xargs, HELP Message-ID: <1991Jul1.005304.11405@thunder.mcrcim.mcgill.edu> Date: 1 Jul 91 00:53:04 GMT References: <15679@ccncsu.ColoState.EDU> Organization: McGill Research Centre for Intelligent Machines Lines: 51 In article <15679@ccncsu.ColoState.EDU>, hallt@handel.CS.ColoState.Edu (Tim C. Hall) writes: > ruptime | grep up | awk '{ print $1 }' | xargs -i -t remsh {} cat /log > Using the -t option of xargs, it echoes the first command formed by > the first "up" host listed in the ruptime, then runs that command. > However, it drops me back into the shell after executing with only > the first host, it doesn't substitute the remainder of the hosts > coming through the pipe. Why? Good question. > Running this command without the xargs portion yields a list of all > our "up" hosts, delimited by a carriage return. More likely a newline.... The most probable thing that comes to mind is that the remsh command being run by xargs inhereits xargs' stdin. And on the assumption that remsh is something like the Berkeley rsh, it doesn't realize that cat isn't interested in reading input, so it copies from its stdin to cat's stdin. Then cat dies, remsh exits, and the other hostnames get dropped when the pipe's buffer is thrown away ('cause cat never read it). If remsh has an option like rsh's -n option, to effectively redirect stdin from /dev/null, use that. If xargs runs a shell to execute the command, you may be able to do .... | xargs -i -t remsh {} cat /log \< /dev/null Based on an experiment with sh here, you may also be able to do .... | xargs -i -t sh -c 'remsh $0 cat /log