home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume3
/
vms-unix
< prev
next >
Wrap
Internet Message Format
|
1989-02-03
|
3KB
Path: xanth!mcnc!gatech!mandrill!hal!ncoast!allbery
From: jacobson@eecs.UUCP
Newsgroups: comp.sources.misc
Subject: v03i060: VMS --> UNIX file name converter, using emacs backup numbers
Message-ID: <8806252107.aa26972@gamma.eecs.nwu.edu>
Date: 26 Jun 88 02:07:24 GMT
Sender: allbery@ncoast.UUCP
Reply-To: jacobson@eecs.UUCP
Lines: 100
Approved: allbery@ncoast.UUCP
comp.sources.misc: Volume 3, Issue 60
Submitted-By: "A. Nonymous" <jacobson@eecs.UUCP>
Archive-Name: vms-unix
Hello, here is a little converter program I made. It has a few (2?)
Berkeleyisms noted (move_flag, PATH). I'm sorry about my cheap "shar"
(we should get a new one), and that I don't have a copy of your
posting rules handy.
# This is a shell archive. Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by jacobson at gamma.eecs.nwu.edu on Sat Jun 25 20:04:19 1988
#
# This archive contains:
# vms-unix
#
# Error checking via wc(1) will be performed.
# Error checking via sum(1) will be performed.
echo x - vms-unix
cat >vms-unix <<'@EOF'
#!/bin/sh
#(Author: Dan Jacobson [jacobson@eecs.nwu.edu])
#Takes VMS filenames and backups and converts to a more UNIX style of
#filenames and GNU Emacs style backups. For example:
#POO.TXT;13 POO.TXT;14 POO.TXT;15 become
#poo.txt.~13~ poo.txt.~14~ poo.txt
#usage example: thisfile * (or quoted filenames to avoid ";"'s)
#Converts VMS style filenames to lower case, ";" is dropped, all but
#highest version number are converted to GNU Emacs backup style
#numbering. You might ftp the files to UNIX to their own directory,
#then run this file on them. was running a version of ftp that made
#this conversion file necessary. Non VMS style files shouldn't get
#disturbed by this program.
#comment this out (or put a switch around it to test) for non Berkeley Unixes:
move_flag=-i
PATH=/usr/ucb:/bin:/usr/bin:/usr/local/bin #a standard safe path on my machine
case $# in 0)
echo "$0: usage: `basename $0` * (or quoted filenames)" >&2; exit 1
;;
esac
#doesn't convert null (".;22") VMS filenames (they would map to ".")
set dummy `ls -d $*| #-d: don't expand subdirectories
sort +t\;nr1| #would like to sort on the last field
#but only expect 1 ";" at most per path anyway
sed -n '
h
#basename
s/.*\///
/^\.[^a-z ;.][^a-z ;.]*;[0-9][0-9]*$/b accept
/^[^a-z ;.][^a-z ;.]*\.[^a-z/ ;.]*;[0-9][0-9]*$/b accept
d
:accept
#it is a vms filename
#print the FROM filename
x; p
#get rid of its basename
s/[^/]*$//
#make the TO filename basename lower case
x; y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
#make the full TO filename, print it
H; x; s/\n//; h; s/;[0-9][0-9]*$//; p
#make the version number, print it
x; s/.*;\([0-9][0-9]*\)$/\1/; p
'`
shift #dummy
while :
do
case $# in 0) break;; esac
oldname=$1 newname=$2 number=$3
if test -r $newname
then #make it into an GNU emacs style numbered backup
mv $move_flag $oldname $newname.~$number~
else #was the highest numbered VMS version
mv $move_flag $oldname $newname
fi
shift; shift; shift
done
@EOF
set `sum <vms-unix`; if test $1 -ne 34596
then
echo ERROR: vms-unix checksum is $1 should be 34596
fi
if test "`wc -lwc <vms-unix | sed -e 's/ */:/g'`" != ':65:301:2003'
then
echo ERROR: wc results of vms-unix are `wc -lwc <vms-unix | sed -e 's/ */:/g'` should be :65:301:2003
fi
chmod 755 vms-unix
exit 0