Complete the CGI script (by filling in the five blanks) which produces in JSONformat data on all the
executablefiles that are in the Unix directory provided as a URL parameter. NR: line number
NF: number of fields in a record Example JSON string:
[
{
“file_name”:”main.sh”,
“user”:”tom”,
“group”:”root”,
“size”:”1024″,
“date”:”2018-11-1″
},
{
“file_name”:”main.sh”,
“user”:”tom”,
“group”:”root”,
“size”:”1024″,
“date”:”2018-11-1″
},
]
File 1: ls2json.cgi
#!/bin/sh
echo Content-Type: application/json; echo directory=”$QUERY_STRING”
( echo “permissions links user group size date time time_offset file_name” ; ( ls -l –full-time $directory
| awk ’ (1) {print (2) }’ ) ) | ./txt2json
File 2: txt2json
#!/bin/sh awk ’NR==1 {
print “[“
for (i=1;i<=NF; i++) name[i]=$i; n=NF
next
} NF>=n {
for ( (3) )
$i=””” name[i] (4) $i “”””