Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a function from file on the UNIX command line

Status
Not open for further replies.

Benjamin

Programmer
Jan 12, 2000
10
US
Help!<br>
<br>
I've been working on this for the past few days and couldn't get this to work. I wrote a function InRange which returns a 1 if a time is within the range of another time. It works when I test it out with a body inside the inrange.awk script:<br>
<br>
cat b ¦ awk -F&quot; &quot; -f inrange.awk -<br>
<br>
where b contains one line with the time: 12 00 14 23 59 24 16 00 00<br>
The first three number is the starting time 12:00:14 and the next three is the end time 23:59:24. The function will check to see if the time 16:00:00 lies between the starting and ending time. awk -F&quot; &quot; separates all the numbers into variables $1, $2, $3... inrange.awk contains the function definition and a body for execution:<br>
{ print &quot;Function returns&quot;, InRange($1,$2,$3,$4,$5,$6,$7,$8,$9) }<br>
<br>
When I execute the above script, it works fine. All outputs are as anticipated.<br>
<br>
But what I was required to do is:<br>
<br>
cat b ¦ awk -F&quot; &quot; -f inrange.awk '{ print &quot;Function returns&quot;, \<br>
InRange($1,$2,$3,$4,$5,$6,$7,$8,$9) }'<br>
<br>
I want to be able to generate the file b (or echo it in on the fly) and change the execution body when needed dynamically. The function in inrange.awk is too large to put it all in the command line. The result of the above execution shows nothing. I see no output from the print command even if I don't call the InRange function. There are no errors either. Does anyone know a way to do this or have similar functions already written? Many thanks for your help.<br>
<br>
Thanks again,<br>
Benjamin<br>
<A HREF="mailto:benjaminle@engineer.com">benjaminle@engineer.com</A>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top