how do I write a script to checkout a file in cvs and cat the file into a file in my home directory
Commands are
cd /home/smr/sandbox
cvsroot
choose option 1
cvs co filename
cat filename > /home/smr/newfilename
Thank you!
how do I write a script to checkout a file in cvs and cat the file into a file in my home directory
Commands are
cd /home/smr/sandbox
cvsroot
choose option 1
cvs co filename
cat filename > /home/smr/newfilename
Thank you!
#!/bin/sh
cd some-dir
if test "$?" = "0"
then
if cvs co filename
then
cp filename $HOME/filename
fi
fi
Thank you for the reply. I am really new to scripting so it is very important that I understand the syntax.
I want it to be a korn script so is the only change there is:
#!/bin/sh to #!/bin/ksh
cd some-dir - understand this
if test "$?" = "0" - what does this mean
then - i know that if whatever above means do this below
if cvs co filename - why can if statement? cuz if the file is not found?
then - once the file is checked out do below
cp filename $HOME/filename
fi
fi
Thanks again!!!
$? is the return code of the previous program.
The "if" command runs a program given as it's arguments and depending on the zero/non-zero return code either runs the then or the else leg.
The "test" command will evaluate it's arguments and set its return code.
cvs is a program that will also set it's return code, hence can be used with if.
Why does it have to be korn shell?
$? is the return code of the previous program. - you mean the cd part of the script? Please bear wtih me when I say I'm new to script I mean really new.
We use korn at work so I just want to try to keep it the same.