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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nothing in getline

Status
Not open for further replies.

deanjco

Technical User
Sep 12, 2000
1
0
0
US
Hi

Can some one please tell me what I am doing wrong, I have entered the code as below but I don't seem to be getting anything in the line variable it comes back blank


else if ( des == "86" ) {
getline line < &quot;temp86.$$&quot;
if ( FILENAME ~ /mdata/ ) {
if ( allofit == line ) {
m86tot = substr(allofit,43,10)
}
}
else if ( FILENAME ~ /udata/ ) {
if ( allofit == line ) {
u86tot = substr(allofit,43,10)
}
}
}
[sig][/sig]
 
It appears to be a problem with the shell expanding
the temporary file name by changing the extension
to the next process number.

Simplified, temp.$$ may have originally expanded into
&quot;temp86.2069&quot; when created, but when awk trys to
open this temp file, the shell expands it into some
other extension number ( temp86.2172 ) which, of
course does not exist!

Therefore, nothing can be written into variable &quot;line&quot;
except &quot;&quot;. (NULL)

To get around this, set a shell variable to the file name
expansion when the temp file is created and pass it
into your program using this construct:

Shell variable-

myfile=&quot;temp86.$$&quot; # at creation

In awk file:

getline line < &quot;'$myfile'&quot; # note quoting!

I recommend using nawk/gawk/mawk for doing this
and running in the Bournce shell.

Hope this helps!

[sig]<p>flogrr<br><a href=mailto:flogr@yahoo.com>flogr@yahoo.com</a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top