awk: "not enough arguments to satisfy format string" error in script
<p>I created a script to grab the data from our Unix server, however I am getting the below error:</p>

<pre><code>awk: cmd. line:8: (FILENAME=- FNR=2) fatal: not enough arguments to satisfy format string
    `|%-17s|%-16s|%-15s|'
                     ^ ran out for this one
</code></pre>

<p>Below is the complete script:</p>

<pre><code>#!/bin/sh
export TERM=xterm
ipath=/usr/local/nextone/bin
date=$(date +"%Y%m%d%H%M")
ifile="$(date '+/var/EndpointUsage_%I-%M-%p_%d-%m-%Y.csv')"
"$ipath"/cli iedge list | awk '
BEGIN { print "|-----------------|------------------|------------------|";
printf "|%-18s|%-17s|%-16s|\r\n","Registration ID", "Port", "Ongoing Calls"
}
/Registration ID/ { id = $3; next }
/Port/ { port = $3 ; next }
/Ongoing Calls/ {print "|-------------------|-----------------|------------- -----|";
printf "|%-18s|%-17s|%-16s|\r\n",id,port,$3 }
END{
print "|------------------|------------------|------------------|";
}'&gt;&gt; "$ifile"
</code></pre>

<p>Can anyone please help me on this, how can I resolve this error? </p>

<p><strong>AFTER CHANGES</strong> the columns are showing correctly, but the <code>Port</code> column does not have any data.  It should have 0 or if other endpoint have 1 o 2 Port number.</p>

<pre><code>|-----------------|------------------|------------------|
|Registration ID   |Port             |Ongoing Calls   |
|-------------------|-----------------|------------------|
|-------------------|-----------------|------------------
|CC_XXXXXX_01_0     |                 |174             |
|-------------------|-----------------|------------------|
</code></pre>