Hide status value from awk system command

Hi,
When i use the system( ) function inside a awk, i am getting the ouput with a 0 appended in a new line.

Can someone guide me to eliminate the extra line containing 0.

Ex :

awk -F"|" '{print system("convert.sh" $1}'

The output is displayed with 0 in a new line.

v7126-6528-6230-6530
0

I expect the o/p as follows :

v7126-6528-6230-6530

Thanks..

A possible workaround:

awk -F"|" '{"convert.sh" $1|getline converted; print converted}'

Thanks for your help, but quiet unfortunately doesn't work. Is there any other help.

Is that the o/p the doesn't return the expected or the awk command that fails? What error message?

Give it another try like this:

 awk -F"|" '{sprintf("convert.sh %s",$2) |getline cvrtd;print cvrtd}' file

That's a weird print command. The system function returns the exit code of the command, the 0 is the return code of your command.

What are you trying to achieve? Clarify your question.
Post your code within code tags and be more precise, the code you posted isn't correct.

Hi,
Thanks a lot for the valuable help..

The command that you gave last worked fine, but then the issue am facing now is i need to print some values before the execution of script.

This is what actually am trying for :

awk -F"|" '{print $1,$2,$3,system("echo" $4),$5,$6,system("convert.sh" $12 $13 $9 $10)}' input_file

when i was trying this command i was facing the issue with the exit status.

But then the command you provided replaced the system , but then i am not able to get the previous values printed.

Please advise..

---------- Post updated at 10:42 PM ---------- Previous update was at 10:23 PM ----------

Hi,
To make it more precise :

The input file content:

file name : input_file

2012                 | TEST | TEST1   |              14031 |      276500 |  TST2               |  334FAAA     |       124706 |       274506 |      2142767 |       346329 |  x'55'         |  x'4F'                 |            0 |       40 |        0
 

Code tried :

Code :

awk -F"|" '{print $1,$2,$3,system("echo" $4),$5,$6,system("convert.sh" $12 $13 $9 $10)}' input_file

Expected output :

2012 TEST TEST1 14031 276500 TST2 2012 TEST TEST1 14031 276500 TST2 v7126-6528-6230-6530-YOA1-274506-85-79-2142767

the last value v7126-6528-6230-6530-YOA1-274506-85-79-2142767 is the output from the convert.sh.

But the output that i currently get is :

2012 TEST TEST1 14031 
0 276500 TST2 v7126-6528-6230-6530-YOA1-274506-85-79-2142767
0

Thanks !

---------- Post updated 10-13-09 at 12:15 AM ---------- Previous update was 10-12-09 at 10:42 PM ----------

Can somebody help??

How about something like this:

awk 'BEGIN { FS = "[ |]+" } { "./convert.sh " $12 $13 $9 $10 | getline con; "echo " $4 | getline ech; print $1,$2,$3, ech, $5, $6, con; }' input_file

I was experiencing something similar today. Try this:

awk -F"|" '{print $1,$2,$3,system("echo" $4),$5,$6,system("convert.sh" $12 $13 $9 $10) 2>/dev/null }' input_file

It worked in my situation, hopefully, it'll work in yours.

don't you require a space after echo and convert.sh?
This is just a guess, I am not sure though.