Need help with a post-processor


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help with a post-processor
# 1  
Old 11-23-2006
Need help with a post-processor

So here is a snippet from an analysis of test runs conducted in a robot experiment in the form of a table:

-----------------------------
| TN | TE | PA | PB |
-----------------------------
| Y | N | - | B |
| N | Y | A | B |

TN = Is the target north?
TE = Is the target east?
PA = Is there a passage ahead?
PB = Is there a passage behind?


How would I go about in writing a BASH script that accepts from the standard input for example:

Code:
echo "| Y | N | - | B |" | ./test

(Straight into the terminal)

And give the output "Target is north, passage behind" for that particular example? This script must take into condition all possible scenarios when conducting the test.

Another example would be:
Code:
 echo "|       N       |     Y     |       A      |      B      |" | ./test

This would output on the standard out "Target is east, passage ahead, passage behind". If anyone can hint me in the right direction then that would be truly appreciated!
# 2  
Old 11-23-2006
something to start with.
Code:
echo '| Y | N | - | B |' | nawk -f ret.awk

ret.awk:
Code:
BEGIN {
  FS="|"

  split("|Target is north|Target is east|Passage is ahead|Passage is behind", whereA, "|")
  howN=split("| Y | Y | A | B ", howA, "|")
}

{
   for(i=2; i <= howN; i++)
     if ( $i == howA[i] )
        printf("%s%s", whereA[i], (i==howN) ? "\n" : ",")
}


Last edited by vgersh99; 11-23-2006 at 01:59 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help for processor

hello Admins, how to find number of processor in unix machine. (2 Replies)
Discussion started by: vipinkumarr89
2 Replies

2. Shell Programming and Scripting

m4 processor (how to use)

hi, what plugins i need to install to run m4 processor in bash shell. Also, what is the file extension for m4 processor ( like .cc in c ). Thanks (1 Reply)
Discussion started by: Learnerabc
1 Replies

3. AIX

Processor failed

Processor failed on POWER 5 machine, i have other "test" machine with different machine type, can i recover the production machine by moving its disks and HBAs to the other test machine ?? (4 Replies)
Discussion started by: majd_ece
4 Replies

4. UNIX for Dummies Questions & Answers

Processor id/name

How to find out whether the system has multiple processors. In multiprocessor system how to get their names or ids How to send command to a particular processor ( can we use rsh) (6 Replies)
Discussion started by: anjum
6 Replies

5. AIX

Processor and processor core

Guys... Hows it going??? I have been going through the hardware spec of IBM system p systems.. and here i am confused for IBM Power 520 Express it says Processor cores: One, two or four 64-bit 4.2 GHz POWER6 with AltiVec™ SIMD and Hardware Decimal Floating-Point acceleration ... (1 Reply)
Discussion started by: balaji_prk
1 Replies

6. UNIX for Dummies Questions & Answers

Processor info

How to get the processor information regarding 32 bit or 64 bit processor (2 Replies)
Discussion started by: aju_kup
2 Replies

7. AIX

LPAR processor/virtual processor settings

Question is on setting of Physical and Virtual processors for LPARs to make proper use of virtualization capabilities. Environment is a 8-way p570 with 4 LPARs. lparVIO1 and lparVIO2: AIX 5300-04-01 Mode/Type= Shared-SMT/Capped Minimum Processors= 0.10 Desired Processors= 0.50 Maximum... (1 Reply)
Discussion started by: guttew
1 Replies

8. Shell Programming and Scripting

How to get Processor Id

Hi Everyone I am new to unix. I ahve few quries that i would like to post. Is there any way by which i get the unique processor Id. Actually i am unable to find any logic and method to get access to Processor Id. Is it possible to get it. I read it on Intel site that the new processor do no... (1 Reply)
Discussion started by: atul.saxena
1 Replies

9. UNIX for Dummies Questions & Answers

Processor

From a PROM ok prompt I have typed banner. This returned this info SunSPARCStation20 (1X390Z50) ...... Okay, I read that the 1x390z50 is the processor type. How can I found out the speed of these processor? Is it 50mhz? Don't know but I am curious. Thanks (5 Replies)
Discussion started by: jwbrown
5 Replies
Login or Register to Ask a Question