Bash variable and cp commands (Solaris 10)

Hi All,

using a product to deploy this script to Solaris 10 servers.....package is downloaded to /tmp and then run to install the files.....Any ideas why script below would fail with the following output?

Output:

 
./installer.sh

PCN0087
making directory /data/PCN/pcn087
cp: /data/PCN/pcn087: is a directory
cp: cannot access pcn087.sh
cp: data/PCN/pcn087: is a directory
cp: cannot access uninstall087.sh

Script being run:

!/bin/bash
# install script - read pcn number from pcn.ver file
VERSION="`cat pcn.ver`"
PKGDIR=/data/PCN/pcn${VERSION}
TITLE="PCN${VERSION} "
echo ${TITLE}
echo making directory ${PKGDIR}
mkdir -p ${PKGDIR}
cp -f pcn.ver ${PKGDIR}
cp -f pcn${VERSION}.sh ${PKGDIR}
cp -f uninstall${VERSION}.sh ${PKGDIR}
cd ${PKGDIR}

.....if i change the first cp line to:

 
cp pcn.ver ${PKGDIR}/pcn.ver 

i get a message saying that the file is not a directory. but if I run the same commands on commandline it works ok :confused:

would be most greatful anybody could explain why this wont work from a script and suggest a solution.

Hello purct and welcome to the forum.
Please use CODE tags (that icon with the text 'code' on it), for each of the code segments, which you agreed upon joining the forum.

Other than that, you are trying (not limited to this example) to overwrite $PKGDIR with the script uninstall$VERSION.sh by 'forcing' it using -f .
The -f toggle usualy is used to overwrite without asking if the target file is already existing, however, since the target you passed is a directory, it will fail.

On the terminal you probably 'missed' to type the -f .

Hope this helps

Thanks -- will give that a go!

NOTE: Appologies for missing the code tags (I have corrected)