Bash variable and cp commands (Solaris 10)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash variable and cp commands (Solaris 10)
# 1  
Old 05-29-2015
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:
Code:
 
./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:
Code:
!/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:

Code:
 
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 Smilie

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

Last edited by purct; 05-29-2015 at 11:21 AM..
# 2  
Old 05-29-2015
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
This User Gave Thanks to sea For This Post:
# 3  
Old 05-29-2015
Thanks -- will give that a go!

NOTE: Appologies for missing the code tags (I have corrected)
This User Gave Thanks to purct For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using commands within bash script

The purpose of enclosed script is to execute selected command and output success or failure in whiptail msgBox Works as expected when command returns zero to msgBox. I cannot figure out how to continue / automate my script when command expects reply to continue / terminate. I am doing it... (2 Replies)
Discussion started by: annacreek
2 Replies

2. Shell Programming and Scripting

How to run several bash commands put in bash command line?

How to run several bash commands put in bash command line without needing and requiring a script file. Because I'm actually a windows guy and new here so for illustration is sort of : $ bash "echo ${PATH} & echo have a nice day!" will do output, for example:... (4 Replies)
Discussion started by: abdulbadii
4 Replies

3. Shell Programming and Scripting

Parallelize bash commands/jobs

Hello, I have a bunch of jobs (cp, cat or ln -s) on big files (10xGB in size): # commands_script.sh: cp file1 path1/newfile1 cp file2 path1/newfile2 cp file3 path1/newfile3 ...... cat file11 path2/file21 path1/newfile11 cat file12 path2/file22 path1/newfile12 cat file13 path2/file23... (5 Replies)
Discussion started by: yifangt
5 Replies

4. Shell Programming and Scripting

Combine several commands in a bash script

Hi all, I have large files with url-s ending on "|<number>" which is the Page Rank for the website as shown in the example below http://www.machinokairo.com/2012/05/post-39.html|2 I am using "grep" to sort out all url-s in a particular way: first, remove all ending on "|0" and write the... (9 Replies)
Discussion started by: georgi58
9 Replies

5. Shell Programming and Scripting

Bash scripts as commands

Hello, the bulk of my work is run by scripts. An example is as such: #!/bin/bash awk '{print first line}' Input.in > Intermediate.ter awk '{print second line}' Input.in > Intermediate_2.ter command Intermediate.ter Intermediate_2.ter > Output.out It works the way I want it to, but it's not... (1 Reply)
Discussion started by: Leo_Boon
1 Replies

6. Shell Programming and Scripting

Running BASH commands from a variable

I am trying to assign a command to a variable and use it. I have tried every possible quoting variation except the correct one. :confused: Here is an example: CMD="grep description $i | grep "::"" $CMD | nawk ...Thanks in advance for you help. (1 Reply)
Discussion started by: aschera
1 Replies

7. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

8. Shell Programming and Scripting

bash and ksh: variable lost in loop in bash?

Hi, I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh). The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Discussion started by: estienne
2 Replies

9. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies

10. Shell Programming and Scripting

running commands from outside of bash

Hello all! I have two consoles.I know the PID of these two.Now I want to execute a command in console#1 but from console#2. How can I achieve this? Anyone can do something for my query? Click here if you can't understand my query or to know the need for this query. (3 Replies)
Discussion started by: rakabarp
3 Replies
Login or Register to Ask a Question