home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume3 / vms-unix < prev    next >
Internet Message Format  |  1989-02-03  |  3KB

  1. Path: xanth!mcnc!gatech!mandrill!hal!ncoast!allbery
  2. From: jacobson@eecs.UUCP
  3. Newsgroups: comp.sources.misc
  4. Subject: v03i060: VMS --> UNIX file name converter, using emacs backup numbers
  5. Message-ID: <8806252107.aa26972@gamma.eecs.nwu.edu>
  6. Date: 26 Jun 88 02:07:24 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: jacobson@eecs.UUCP
  9. Lines: 100
  10. Approved: allbery@ncoast.UUCP
  11.  
  12. comp.sources.misc: Volume 3, Issue 60
  13. Submitted-By: "A. Nonymous" <jacobson@eecs.UUCP>
  14. Archive-Name: vms-unix
  15.  
  16. Hello, here is a little converter program I made.  It has a few (2?)
  17. Berkeleyisms noted (move_flag, PATH).  I'm sorry about my cheap "shar"
  18. (we should get a new one), and that I don't have a copy of your
  19. posting rules handy.
  20.  
  21. # This is a shell archive.  Remove anything before this line,
  22. # then unpack it by saving it in a file and typing "sh file".
  23. #
  24. # Wrapped by jacobson at gamma.eecs.nwu.edu on Sat Jun 25 20:04:19 1988
  25. #
  26. # This archive contains:
  27. #    vms-unix    
  28. #
  29. # Error checking via wc(1) will be performed.
  30. # Error checking via sum(1) will be performed.
  31.  
  32. echo x - vms-unix
  33. cat >vms-unix <<'@EOF'
  34. #!/bin/sh
  35. #(Author: Dan Jacobson  [jacobson@eecs.nwu.edu])
  36.  
  37. #Takes VMS filenames and backups and converts to a more UNIX style of
  38. #filenames and GNU Emacs style backups.  For example:
  39. #POO.TXT;13    POO.TXT;14    POO.TXT;15 become
  40. #poo.txt.~13~    poo.txt.~14~    poo.txt
  41.  
  42. #usage example: thisfile  * (or quoted filenames to avoid ";"'s)
  43.  
  44. #Converts VMS style filenames to lower case, ";" is dropped, all but
  45. #highest version number are converted to GNU Emacs backup style
  46. #numbering.  You might ftp the files to UNIX to their own directory,
  47. #then run this file on them.  was running a version of ftp that made
  48. #this conversion file necessary.  Non VMS style files shouldn't get
  49. #disturbed by this program.
  50.  
  51. #comment this out (or put a switch around it to test) for non Berkeley Unixes:
  52. move_flag=-i
  53.  
  54. PATH=/usr/ucb:/bin:/usr/bin:/usr/local/bin #a standard safe path on my machine
  55.  
  56. case $# in 0)
  57.     echo "$0: usage: `basename $0` * (or quoted filenames)" >&2; exit 1
  58.     ;;
  59. esac
  60.  
  61. #doesn't convert null (".;22") VMS filenames (they would map to ".")
  62.  
  63. set dummy `ls -d $*|    #-d: don't expand subdirectories
  64.     sort +t\;nr1|    #would like to sort on the last field
  65.             #but only expect 1 ";" at most per path anyway
  66.     sed -n '
  67.     h
  68.     #basename
  69.     s/.*\///
  70.     /^\.[^a-z ;.][^a-z ;.]*;[0-9][0-9]*$/b accept
  71.     /^[^a-z ;.][^a-z ;.]*\.[^a-z/ ;.]*;[0-9][0-9]*$/b accept
  72.     d
  73.     :accept
  74.     #it is a vms filename
  75.     #print the FROM filename
  76.     x; p
  77.     #get rid of its basename
  78.     s/[^/]*$//
  79.     #make the TO filename basename lower case
  80.     x; y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
  81.     #make the full TO filename, print it
  82.     H; x; s/\n//; h; s/;[0-9][0-9]*$//; p
  83.     #make the version number, print it
  84.     x; s/.*;\([0-9][0-9]*\)$/\1/; p
  85.     '`
  86. shift #dummy
  87. while :
  88. do
  89.     case $# in 0) break;; esac
  90.     oldname=$1 newname=$2 number=$3
  91.     if test -r $newname
  92.         then #make it into an GNU emacs style numbered backup
  93.             mv $move_flag $oldname $newname.~$number~
  94.         else #was the highest numbered VMS version
  95.             mv $move_flag $oldname $newname
  96.     fi
  97.     shift; shift; shift
  98. done
  99. @EOF
  100. set `sum <vms-unix`; if test $1 -ne 34596
  101. then
  102.     echo ERROR: vms-unix checksum is $1 should be 34596
  103. fi
  104. if test "`wc -lwc <vms-unix | sed -e 's/  */:/g'`" != ':65:301:2003'
  105. then
  106.     echo ERROR: wc results of vms-unix are `wc -lwc <vms-unix | sed -e 's/  */:/g'` should be :65:301:2003
  107. fi
  108.  
  109. chmod 755 vms-unix
  110.  
  111. exit 0
  112.