Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004

    Unanswered: awk results not stored properly


    Getting unexpected results from the script line below. I expect to get 3rd parm from each grep'd line into tmp3.out, but I end up getting all 4 parms from each grep'd line (each line contains 4 parms).

    ssh $1 "prog1 | grep data | awk '{print $3}';" > tmp3.out

    Any ideas on what I am doing wrong here?

    Also, tmp3.out is created on host machine. If I want to create tmp3.out on target machine the following doesn't work.

    ssh $1 "prog1 | grep data | awk '{print $3}' > tmp3.out ;"
    Last edited by hgwells3; 07-11-04 at 13:11.

  2. #2
    Join Date
    Apr 2004
    Boston, MA
    what does the input to awk look like?
    have you tried the awk portion of the "pipe" stand-alone?
    | #include <disclaimer.h> |

  3. #3
    Join Date
    Jul 2004

    Thanks again for responding, much appreciated.
    I don't have a copy of the input here in front of me, but each line has 4 text fields (10 chars or less) separated by spaces.

    The weird thing is, if I run the exact same thing from the command-line, it works fine with correct output (3rd field only). I run it in the script and I get the whole line.

    From the command line, I do it in 2 steps:
    1) ssh <ip-addr>
    2) prog1 | grep data | awk '{print $3}' > tmp3.out

    Of course, with the command-line version, tmp3.out ends up on the target machine.


  4. #4
    Join Date
    Jul 2004
    Figured this one out, this does the trick:

    ssh $1 "prog1 | grep data" | awk '{print $3}'; > tmp3.out

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts