Here's what I have so far
Code:
#!/bin/csh -f
set params = $argv[1-]
set argc = $#argv
set lsval = `ls`
set title = "File Index"
#defines head
echo "<html>"
echo "<head>"
echo "<title>"
echo "$title"
echo "</title>"
echo "</head>"
echo "<body>"
echo "<h1>"
echo "$title"
echo "</h1>"
echo "<hr>"
echo "<table>"
#begin loop
set var = `ls`
foreach a($var)
echo "<tr>"
echo "<td>"
echo "<pre>"
echo " $a "
echo "</pre>"
echo "</td>"
echo "</tr>"
end
#loop end
#defines bodyend
echo "</table>"
echo "<hr>"
echo "<address>"
echo "Generated by $USER@`hostname` from $HOME"
echo "</address>"
The problem I have now, is that I don't know how to 'scan' the argument list stored in argv. Ideally, I want the program to be run
uprompt> ./htx2 *.html > index.html
So this means whatever the extension is , say *.c *.h, the script will find it in argv, and place it in var, so var = `ls *.html` say. Then only files with the html extension will be listed in the html file.
How can I do this. I've tried and cannot seem to get it. The users input, *.html, or *.c or whatever, can occur anywhere in the argv line. So it could follow other switches, whatever. How can I scan the line, and pass the search term to ls?