Novice needs help with running a script through a pipe 
Author Message
 Novice needs help with running a script through a pipe

I'm making a simple script to just add 2 numbers, but then that number
needs to be piped back and added to another number.  I thought that I
could use getline, but thats where I'm recieving an error.  Rather
than try to explain, here is my code.

#called add2
nawk 'BEGIN \
{
 if (ARGC==3)
 {
  solution=ARGV[1]+ARGV[2]
  printf "%d\n",solution
 }
 else if (ARGC==2)
 {
  getline numb
  solution=ARGV[1]+numb
  printf "%d",solution
 }

Quote:
}' $*

Problem: add2 2 3|add2 4

Should get 9, but I recieve an error at getline, can anyone help me
with a command on how to do this?

Phiz



Fri, 10 Sep 2004 15:15:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Novice Needs help with piping

2. Need help on configuring IIS to run jython-scripts (CGI)

3. RB Novice needs help

4. Novice needs help with SQL (Max,Min, etc) queries on RealDBs

5. Allen TX C55 novice needs help

6. Novice Needs CW4.0 help

7. Novice Needs Help with complicated report design.

8. Novice needs help....

9. COBOL novice needs test help

10. Novice needs help with FX Ruby

11. Novice Needs Help with Memory Dump Program

12. Need help with Verilog (novice).

 

 
Powered by phpBB® Forum Software