mitanu@goedel.top.cis.syr.edu (Mitanu Paul) (06/20/91)
Hi, I have tried to use awk with rsh, rsh spica "ps -l | awk '{ print $4}'" and here is what I get: F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND 20488200 109 2548 2547 1 15 0 96 0 kernelma IW pc 0:00 -csh (csh) 20008000 109 2599 2548 0 1 0 292 0 select IW pc 0:05 emacs p2.pl Question: Is this a bug of awk or that of rsh? Is there something which I am missing? Please send me e-mail at mitanu@top.cis.syr.edu If there is enough interest, I'll post a summary. I know the following: 1. awk works OK on the remote machine. The command ps -l | awk '{ print $4}' gives the desired output on spica. 2. Commands like rsh spica "ps -l | wc" work OK. Thanks. -- Mitanu Paul
wittig@gmdzi.gmd.de (Georg Wittig) (06/21/91)
mitanu@goedel.top.cis.syr.edu (Mitanu Paul) writes: > rsh spica "ps -l | awk '{ print $4}'" > >and here is what I get: > > F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND >20488200 109 2548 2547 1 15 0 96 0 kernelma IW pc 0:00 -csh (csh) >20008000 109 2599 2548 0 1 0 292 0 select IW pc 0:05 emacs p2.pl > This is a quoting problem of your shell. Try rsh spica 'ps -l | awk '"'"'{ print $4}'"'" -- Georg Wittig GMD-Z1.IT P.O.Box 1240 | "Freedom's just another word D-W-5205 St. Augustin 1 (Germany) | for nothing left to lose" email: wittig@gmdzi.gmd.de | (from "Me and Bobby McGee", telephone: (+49) 2241 14-2294 | Janis Joplin, Kris Kristofferson)
suresh@uts.amdahl.com (Suresh Padmanabhan) (06/22/91)
In article <1991Jun19.143911.22217@rodan.acs.syr.edu>, mitanu@goedel.top.cis.syr.edu (Mitanu Paul) writes: > > I have tried to use awk with rsh, > rsh spica "ps -l | awk '{ print $4}'" > and here is what I get: > > F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND > 20488200 109 2548 2547 1 15 0 96 0 kernelma IW pc 0:00 -csh (csh) > 20008000 109 2599 2548 0 1 0 292 0 select IW pc 0:05 emacs p2.pl > > Question: > Is this a bug of awk or that of rsh? Is there something which I am missing? You ARE missing something. The trick is to hide the metacharacters from the shell at the server end . Try the following syntax : remsh spica "ps -ef| awk '{print \$4}'" Hope this helps. ***************************************************************************** Suresh Padmanabhan (suresh@uts.amdahl.com) Amdahl Corp. Phone:(408)737-5738 ***************************************************************************** -- ***************************************************************************** Suresh Padmanabhan (suresh@uts.amdahl.com) Amdahl Corp. Phone:(408)737-5738 *****************************************************************************
mouse@thunder.mcrcim.mcgill.edu (der Mouse) (06/22/91)
In article <1991Jun19.143911.22217@rodan.acs.syr.edu>, mitanu@goedel.top.cis.syr.edu (Mitanu Paul) writes: > rsh spica "ps -l | awk '{ print $4}'" I've seen several fixes posted, but none that actually explain what's going on. So here goes.... The problem is that the $4 is being interpreted locally. This is a consequence of the quoting rules: while it's true that $ syntax isn't processed inside single-quoted text, those single quotes don't cause the text between them to be single-quoted, because they are themselves quoted by the double quotes. (On spica, of course, the whole string gets another parse, and this time the single-quotes *do* cause the stuff between them to be single-quoted...but by that time the $4 has already been replaced with whatever $4 was on the source machine.) Thus, it's as if you'd said rsh spica "ps -l | awk '{ print }'" which of course explains the result. With this in hand, you should be able to deduce your own fix, or see why the various posted ones work...the working ones, that is! (Which in this case is most of them, perhaps even all (I haven't been paying close attention).) der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu
rick@ulticorp.UUCP (Rick Poleshuck) (06/25/91)
In article <1991Jun19.143911.22217@rodan.acs.syr.edu> mitanu@top.cis.syr.edu (Mitanu Paul) writes: >Hi, > >I have tried to use awk with rsh, > > rsh spica "ps -l | awk '{ print $4}'" > >and here is what I get: > > F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND >20488200 109 2548 2547 1 15 0 96 0 kernelma IW pc 0:00 -csh (csh) >20008000 109 2599 2548 0 1 0 292 0 select IW pc 0:05 emacs p2.pl > > I suspect that you have solved this problem already, but here is the line that you meant to type, anyway. rsh spica "ps -l | awk '{ print \$4}'" Your problem was in your understanding of the local shell and how it handles quotes and double quotes. You assumed that because the $4 was inside single quotes the local shell would leave it alone, however, the single quotes were surrounded by double quotes and lost any special meaning. Try this example: echo "'$0'" The $0 is expanded by /bin/sh because the single quotes are quoted. -- | Email - !uunet!ulticorp!ultixrs!rick Rick Poleshuck | Voice - (201) 887-9222 Ext. 3755 | Mail - The Ultimate Corporation, East Hanover, NJ 07936
mitanu@goedel.top.cis.syr.edu (Mitanu Paul) (06/26/91)
I'd like to thank several people who have responded to my initial query about the command rsh spica "ps -l | awk '{ print $4}'" One solution (by wittig@gmdzi.gmd.de (Georg Wittig)), which works for my case, is to use rsh spica 'ps -l | awk '"'"'{print $4}'"'" to avoid $4 being interpreted locally. suresh@uts.amdahl.com (Suresh Padmanabhan) suggested rsh spica 'ps -l | awk '{print \$4}'" which work on UTS. I'd like to thank mouse@thunder.mcrcim.mcgill.edu (der Mouse) for his article in helping understand the problem. -- Mitanu Paul.