1833536 Members
3130 Online
110061 Solutions
New Discussion

Re: Script needed

 
SOLVED
Go to solution
Hunki
Super Advisor

Script needed

We need to have script through which I can get a list of latest version numbers only ..like 1.20 along with the filename from which it comes.

The command which I use to get the version history is called "sccs prs filename"

Here is the example , it lists the latest version on the top and then then subsequent version below. I only need the latest version and the filename from the script and put it into an excel sheet for records.
-------------------------------------
$ sccs prs filename
filename

D 1.20 06/11/27 12:23:34 userid1 25 24 00012/00012/01066
MRs:
COMMENTS:
xxxx

D 1.19 06/10/12 08:21:45 userid1 24 23 00006/00006/01072
MRs:
COMMENTS:
xxx

D 1.18 06/10/06 09:33:49 userid1 23 22 00004/00004/01074
MRs:
COMMENTS:
xxxx
16 REPLIES 16
OldSchool
Honored Contributor
Solution

Re: Script needed

try either:

sccs prs -d ":Dt:" -r

or

prs -d ":Dt:" -r

one of them should produce just the latest delta number of the filename specified.

man "prs" for more info
Dennis Handly
Acclaimed Contributor

Re: Script needed

You can use this awk script:

$ sccs prs filename | awk '
BEGIN {
getline
filename = $0
getline; getline
VER = $2
print filename "," VER
exit 0
} '

For your above input, it prints:
filename,1.20
Hunki
Super Advisor

Re: Script needed

Thanks for the reply Dennis , what i have is multiple files instead of just one and they are under one parent directory , how to go about getting the info for each file.

Thanks,
hunki
spex
Honored Contributor

Re: Script needed

Hunki,

#!/usr/bin/sh
for file in $(ls /path/to/dir)
do
sccs prs ${file} | awk -f prog.awk
done
exit

PCS
Hunki
Super Advisor

Re: Script needed

Sorry Spex its giving me problems running the script :

awk: can't open prog.awk
ERROR [SCCS/s.$(ls]: `SCCS/s.$(ls' nonexistent (ut4)
ERROR [/appl/solid/develop/SCCS/s.2006.3)]: `/appl/solid/develop/SCCS/s.2006.3)' nonexistent (ut4)
Hunki
Super Advisor

Re: Script needed

Sorry Spex its giving me problems running the script :

awk: can't open prog.awk
ERROR [SCCS/s.$(ls]: `SCCS/s.$(ls' nonexistent (ut4)
ERROR [/xx/xx/xx/s.2006.3)]: `/xx/xx/s.2006.3)' nonexistent (ut4)
Sandman!
Honored Contributor

Re: Script needed

#!/usr/bin/sh

for i in $(ls -1 )
do
sccs prs $i | awk '!/^$/{if(x){x=x" "$2;print x;exit}else x=$0}'
done
Hunki
Super Advisor

Re: Script needed

./check_version.sh: syntax error at line 1 : `end of file' unexpected
Dennis Handly
Acclaimed Contributor

Re: Script needed

>Sorry Spex its giving me problems running the script:
awk: can't open prog.awk

I assume Spex was pointing to my example awk script. Just put my fragment (without the trailing "'" in prog.awk.
Hunki
Super Advisor

Re: Script needed



I ran it again Dennis but this is what I got :(

./check_version: syntax error at line 2: `$' unexpected
Peter Nikitka
Honored Contributor

Re: Script needed

Hi Hunki,

do you work under HP-UX?
If not,
#!/usr/bin/sh
may not start a posix shell. Use
#!/usr/bin/ksh

instead.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Dennis Handly
Acclaimed Contributor

Re: Script needed

As Peter asked, what is your shell and what is its absolute path?

>for file in $(ls /path/to/dir)

This is valid ksh or posix shell syntax and replaces the archaic ``. But it can be simplified to:
for file in path/to/dir/*; do
Peter Godron
Honored Contributor

Re: Script needed

Hi,
combining the pieces of code:

#!/usr/bin/sh
for file in `ls`
do
sccs prs $file | awk '
BEGIN {
getline
filename = $0
getline; getline
VER = $2
print filename "," VER
exit 0
}'
done

Please generate a shell script (a.sh) with the above. Then "chmod 744 a.sh". To run it "./a.sh"
Hunki
Super Advisor

Re: Script needed

There are sub directories also which need to be looked into ( not only the parent dir ) and my shell is ksh.

parent dir : /appl/XXX/XXX/cur .... and there are subdirectories under it which need to be looked into.

Thanks,
hunki
Peter Nikitka
Honored Contributor

Re: Script needed

Hi Hunki,

just change the way the filenames in question are determined:
Change
for file in `ls`
do
...
to something like this:
find YOUR_DIRNAMES -name SCCS -prune -type f -print | while read file
do
...

mfG Peter

PS: Your assignment rate for points is worth to rise...
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Hunki
Super Advisor

Re: Script needed

Thanks specialy to OLD school and also to all of you . I have given you the required points.