If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > awk results not store properly

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-11-04, 12:04
hgwells3 hgwells3 is offline
Registered User
 
Join Date: Jul 2004
Posts: 6
awk results not stored properly

Hi,

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 12:11.
Reply With Quote
  #2 (permalink)  
Old 07-11-04, 15:30
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
what does the input to awk look like?
have you tried the awk portion of the "pipe" stand-alone?
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
  #3 (permalink)  
Old 07-11-04, 19:36
hgwells3 hgwells3 is offline
Registered User
 
Join Date: Jul 2004
Posts: 6
vlad,

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.

hg
Reply With Quote
  #4 (permalink)  
Old 07-12-04, 19:26
hgwells3 hgwells3 is offline
Registered User
 
Join Date: Jul 2004
Posts: 6
Figured this one out, this does the trick:

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On