#!/bin/sh ############################################################### # List the contents of a Directory when no "index.xxx" exists. # - If an executable file 'index' exists, use this one for the # creation of the index e.g. /local/Dic/index # - For catalogues, proposes the various conversions # of the WHOLE CATALOG only. ############################################################### # Requires the host name... test -z "$SERVER_NAME" && SERVER_NAME=`hostname` # dir = relative directory e.g. /local/Dic or /ftp/cats/J/A+A/499/51 dir=`echo "$REQUEST_URI"| cut -d\? -f1` pdir=`dirname $dir` # Execute the 'index' if one exists... if test `expr "$REQUEST_URI" : /local/` -ge 6; then file=`echo "$DOCUMENT_ROOT/$dir" | sed 's%Pages/*local%local/Pages%'` script=/local/viz-bin/`basename $dir` else file="$DOCUMENT_ROOT/$dir" script=/viz-bin/`basename $dir` fi #echo2 "#...is there $file/index ? " if test -x $file/index; then SCRIPT_NAME=$script; export SCRIPT_NAME exec $file/index fi echo "Content-Type: text/html" echo "" #echo DOCUMENT_ROOT=$DOCUMENT_ROOT #echo $DOCUMENT_ROOT/./$REQUEST_URI ; ls -l $DOCUMENT_ROOT/./$REQUEST_URI echo "" echo "
====NotFound exit 0 fi echo "" #echo "
'; echo "dir=$dir"; pwd; ls -lah; echo '' # # The file .message main contain a limit in the number of rows. # #echo "REQUEST_URI=$REQUEST_URI" ls -l $dir/.message | cat2 if test -r $dir/.message; then #echo2 "....REQUEST_URI=$REQUEST_URI" if test `expr "$REQUEST_URI" : '/ftp/.*cats/'` -ge 9; then cat=`echo $REQUEST_URI | tr '&' + | sed s%/ftp/cats/%% | sed 's%/$%%'` url="/viz-bin/Cat?$cat" fi echo -n '
' # Conversions: tar not always possible exts="txt,txt.gz,fits,fits.gz,tar,tar.gz,html" mime="text,gzipped text,FITS,gzipped FITS,tar,tar.gz,html" if test -r .notar; then exts="txt,txt.gz,fits,fits.gz,html" mime="text,gzipped text,FITS,gzipped FITS,html" fi is_submit=`echo $dir|grep vizier.submit` if test "$is_submit" = ""; then # The AWK script adds the conversions. sed 's%\(http:[^ ()]*\)%\1%' $dir/.message \ | gawk -v url="$url" -v cat="$cat" -v exts="$exts" -v mime="$mime" '\ BEGIN{nx=split(exts,x,","); split(mime,t,","); Ucat="/viz-bin/nph-Cat"}\ /max=/{ i=index($0,"max="); m=sprintf("/max=%d",substr($0,i+4)+0) }\ /^===[= ]*$/{printf "%s", "
"; next}\ function show() { if(done>0) return; done++; \ if((url == "")||(cat == "")) return; \ printf " Get the formatted ReadMe file\n",url; \ printf " Get all tables in"; s=" "; for(i=1;i<=nx;i++) {\ printf "%s %s", s,Ucat,x[i],m,cat,t[i];\ s="," } printf "\n
"}\ { line=$0; if($1 == "Query") show(); print line }\ END{ show() }' fi echo '' else # No .message ==> a simple list echo '' fi # The list of files is limited to public ones # (protected files are NOT edited) # ls1 is used to keep the wished order of files. #test -r $dir/.message && (echo ''; cat $dir/.message ; echo '" echo "$SERVER_NAME" echo "" echo ""
' ) # List in reverse order (newest first) for Volumes optr="" test `pwd | grep '/[A-Z][^\/]*$' | wc -l` -gt 0 && optr="r" #echo "### `pwd`" ls1 --time-style=+"%d-%h %Y %H:%M" -Llh$optr \ | grep '^.r..r..r' | gawk -v d=$pdir -v cat="$cat" '\ BEGIN{printf "[DIR] Parent Directory\n",d}\ /^d/{ t="DIR" }\ #{ if (($9 == "ReadMe") && (cat != "")) U="/viz-bin/Cat?" cat; else U=$9;\ { U=$9;\ printf "[%-3s] %s", t, U, $9; \ w=24-length($9); if(w<=0) w=1; while(w-->0) printf " "; \ printf "%s-%s %s",$6,$7,$8;\ printf " %5s\n", $5; t=""}' echo "