The awk variable FILENAME indicates the name of the file being processed (or '-' if stdin). However, this is not possible in the BEGIN block, but instead you can use ARGV [1] (assuming you only pass one file name):
BEGIN {
cmd = "./myscript.py '\"%s20s\"' " ARGV[1]
print cmd
cmd | getline var
print var
}
The python script (py3) that I used for testing was:
import sys
print(sys.argv)
, :
/home/user1> runit.awk afile
./myscript.py "%s20s" afile
['./myscript.py', '"%s20s"', 'afile']