#!/bin/tcsh -f #(ie run the tshell on this but don't read the .cshrc or .tcshrc) echo version = 1.34 of a 2011 Apr 28 # 2011 Apr 28, 1.34: look at all files including dot - failed # 2010 Dec 04, 1.33: -r implementation was missing? # 2010 Dec 04, 1.32: update documentation # 2010 Jun 15, 1.31: for security, don't report the web page location # 2010 Jun 13, 1.30: call mkopenhtml with -s to silence browser opening # 2010 Apr 21, 1.29: implement -q # 2010 Apr 20, 1.28: delete *,*.aw files! # 2010 Apr 20, 1.27: delete *,*.aw files? # 2009 Jun 23, 1.26: correct instructions # 2008 May 15, 1.25: more instructions # 2008 May 02, 1.24: robots told not to index # 2008 Apr 11, 1.23: a .silent.nowhere file is not put in the index # solution: .mkopenhtml.block containing: # .silent.nowhere # 2008 Apr 08, 1.22: ~/.a file has comments; first line used. # 2008 Apr 08, 1.21: silence mechanism (not implemented) # 2007 Sep 01, 1.20: document ~/.a # 2007 May 25, 1.19: determine a directory from ~/.a # 2007 May 14, 1.18: determine a directory from ~/.a # 2006 Sep 25, 1.17: -s for silencing the a directory # 2006 Jul 12, 1.16: -r for remote opening # 2006 Apr 25, 1.15: no clearscreen when building files # 2005 Oct 24, 1.14: mkopenhtml do leaves blank index.html # 2005 Oct 09, 1.13: remove .origin.date # 2005 Apr 27, 1.12: EMPTY surrounded by astrisks # 2005 Feb 15, 1.10: -l says EMPTY when there is nothing in 'a' # 2005 Jan 22, 1.10: upgrade documentation, allow -l # 2005 Jan 19, 1.09: if in 'a' directory, empty, warn user, allow -c # 2005 Jan 6, 1.08: if in 'a' directory, open it. # 2005 Jan 5, 1.06: if in 'a' directory, open it. - not finished # 2004 Nov 6, 1.05: detect missing file # 2004 Oct 31, 1.04: allow single letter file names again # 2004 Oct 18, 1.03: change location to be under projects # 2004 Oct 15, 1.02: don't chmod cl op if they are not in a # 2004 Oct 14, 1.01: fix documentation # 2004 Oct 1, 1.00: origin # Thomas D. Schneider, Ph.D. # National Institutes of Health # schneidt@mail.nih.gov # toms@alum.mit.edu (permanent) # http://alum.mit.edu/www/toms (permanent) # default message: set a = '[the directory needs to be defined in your ~/.a file]' set public = ~/public_html/ # Switch lines to debug. # This controls printing of the a directory location on the screen # so it normally should be off (0). set debugging = 1 set debugging = 0 #if ($argv > 0) then if (-f ~/.a) then set a = `cat ~/.a| grep -v '#'|head -1` if !(-d "$a") then echo "There is no directory" echo "$a" echo "into which files can be put." echo "Don't forget to set permissions." endif else echo 'You need to create a "~/.a" file that contains' echo 'the directory where your files will be put so that they are on the web.' exit endif #endif set me = `whoami` set index = /tmp/${me}.a set doexit = false set arguments = $#argv set autoopen = false set silence = false set quiet = false if (`pwd` == "$a") then set location = 'a' else set location = 'NOTa' endif if ($#argv == 0) then echo 'usage: a [-cl] [-look] [-r] [-s] [-q] [file]' echo "Place the file into your 'a' directory:" echo " $a" echo "and open it for reading on the web." echo "(The 'a' directory location is given in your ~/.a file.)" echo "This allows for a fast and convenient way to put a file on the web." echo "" echo "Flags:" echo "The -cl (or -c) option clears the 'a' directory." echo "The -look (or -l) option shows the 'a' directory." echo "If pwd is the 'a' directory, open it without requiring an argument." echo "The -r option opens the 'a' directory from any pwd." echo " NOTE: -r must be called last in the command line," echo " otherwise, -q won't be done." echo "The -s option silences the 'a' directory from any pwd." echo " That is, the files are untouched but not permitted for reading." echo "The -q option makes aw be quiet instead of announcing the grab." echo echo "The ~/.a file can have comment lines that begin with '#'." echo "Only the first line of the ~/.a is used." echo echo "If you are in the 'a' directory, then it is opened" echo "when there are no arguments (see below)." echo echo "This program uses:" echo "* mkopenhtml to open the directory." echo " mkopenhtml creates an index.html file that tells robots" echo " not to index or follow down into the directory." echo " This is a security feature." echo echo "If you wish to prevent the nowhere link from showing the location" echo "of the 'a' directory, add an empty .silent.nowhere file." echo "To prevent the .silent.nowhere file from being tranported," echo "also create a .mkopenhtml.block file containing" echo "the name '.silent.nowhere'." cat << EOF SET UP INSTRUCTIONS: For help on the a program, just type: a | more For help on the aw program type: aw -help To get started, you need a directory in your home directory: mkdir public_html Then make a projects directory: cd public_html mkdir projects and cd projects mkdir myadirectory (You can use another name for this directory - it's like a password.) chmod a+rx public_html public_html/projects public_html/projects/myadirectory Then put /home/strawberry/`whoami`/public_html/projects/myadirectory into file named .a in your home directory. Finally, in the projects directory add an index file containing: chmod a+r public_html/projects/index.html Tell aw where this is by making a ~/.aw file on your mac containing the url: http://www.ccrnp.ncifcrf.gov/~`whoami`/projects/myadirectory Ok, fire up aw in a terminal on the Mac and let it run: aw Now you just say a my.pdf on the source machine and my.pdf will pop up on the Mac! So, once the a/aw system is configured, rapid transfer of files is very simple. EOF if ($location == 'a') then echo "====> opening the $a directory <====" # pretend there is one argument to allow automatic opening set arguments = 1 set autoopen = true else echo echo "-----------------------------------------------------------" echo "You are not in your 'a' directory, no further action taken." echo "To open remotely use -r." set doexit = true endif endif if !(-d "$a") then echo You do not have a "$a" directory. echo You must build one to use this function. echo The method is: echo ' cd' if !(-d "$public") then echo ' mkdir public_html' echo ' chmod a+rx public_html' endif echo ' cd public_html' set projects = projects if !(-d "$public/$projects") then echo ' mkdir projects' echo ' chmod a+rx projects' endif echo ' cd projects' echo ' mkdir a' echo ' chmod a+rx a' set doexit = true endif if ($doexit == true) then exit endif echo set argcount = 1 while ($argcount <= $arguments) if ($autoopen == true) then set argument = -autoopen else set argument = $argv[$argcount] endif # alternative for -cl is -c if ("${argument}" == '-c') then set argument = '-cl' endif # alternative for -look is -l if ("${argument}" == '-l') then set argument = '-look' endif # implement remote opening, -r if ("${argument}" == '-r') then set argument = -autoopen set autoopen = true endif # implement silence, -s if ("${argument}" == '-s') then set silence = true endif # implement quiet, -q if ("${argument}" == '-q') then set quiet = true endif # switch ($argv[$argcount]) switch ($argument) # case '-help' # echo "$v" # echo "usage: execute the last line in the ./$notes file." # echo "-help this help file" # exit # breaksw case '-cl' if ($debugging) then echo "Closing $a" else echo "Closing 'a'" endif cd "$a" usfn foreach f (`ls | grep -v '^automate$' | grep -v '^cl$' | grep -v '^op$'`) echo wipe $f rm -f $f end # remove the .origin.date file created by mkopenhtml echo y | rm -f .origin.date dirclose breaksw case '-look' if ($debugging) then echo "Contents of $a are:" else echo "Contents of 'a' are:" endif cd "$a" ls -la if (`ls` == "") then echo '****************************' echo '* The a directory is EMPTY *' echo '****************************' else echo `ls | wc -l` FILES endif breaksw case '-s' # echo "the directory will be silenced" # This chunk of code prevents the default process breaksw case '-q' # put quiet marker into the directory #touch $a/quiet-grabs cd $a touch quiet-grabs breaksw default if ($autoopen == false) then if !(-f "$argv[$argcount]") then echo ERROR: there is no file named "$argv[$argcount]" echo in this directory: pwd exit endif # clear $a/*,*.aw files echo 'rm -f $a/*,*.aw' rm -f $a/*,*.aw echo Storing $argv[$argcount] in "$a" cp $argv[$argcount] "$a" endif cd "$a" echo Opening $a # rm -f index.html set arefiles = `ls | head -1` # echo "'"$arefiles"'" if ("$arefiles" == '') then echo echo WARNING: There are no files in "$a" echo WARNING: No action taken. exit endif usfn # diropen if ($#argv == 0) then # prior to 2010 Jun 13: # echo "mkopenhtml -r -s -R > /dev/null" # mkopenhtml -r -R > /dev/null echo "mkopenhtml -r -s -R > /dev/null" mkopenhtml -r -s -R > /dev/null else # prior to 2010 Jun 13: # echo "mkopenhtml -r -R > /dev/null" # mkopenhtml -r -R echo "mkopenhtml -r -s -R > /dev/null" mkopenhtml -r -s -R endif breaksw endsw @ argcount++ end if ($silence == true) then echo "silencing the $a directory" cd "$a" chmod go-r * chmod go-rx . ls -la endif exit ********************************************************************************