Copy Script Stops


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copy Script Stops
# 1  
Old 02-01-2018
Copy Script Stops

Good Morning,

I have a copy script on Solaris 9 machine that is supposed to copy some files to a NAS using:
Code:
cp -r /dir/dir/ /dir/dir/dir

The script doesn't finish. The directory contains user files of which one seems to copy fine, a second was failing until I did a
Code:
chmod -R -777

to it. Now, the copy looks the same as far as I can tell, but the directory for the next users never get created and the script seems to stop. Any ideas why? Normally
Code:
crontab

runs this script, but I am running it manually from root right now.
# 2  
Old 02-01-2018
This command as written
Code:
chmod -R -777

Makes every file + directory (affected by the command) unaccessable. So I do not know what you are trying to do.

Try changing the -777 to 777.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 02-01-2018
Sorry typo there was no -. When I ls -l everything looks right.

Last edited by rbatte1; 02-02-2018 at 04:49 AM.. Reason: Changed CODE tags to ICODE tags
# 4  
Old 02-05-2018
I tried
Code:
cp -r /dir/dir/dir /dir/dir/dir 2>&1 

and no error was reported but it stopped at the same user.
# 5  
Old 02-06-2018
Firstly, it is known that:

Code:
# cp -r <whatever>

can have problems with special files (device nodes e.g. /dev/<whatever>) and also with linked files.

So does including the -v switch (verbose) tell you any more?

Code:
# cp -rv <whatever>

If no success then try -R instead.

Code:
# cp -Rv <whatever>

Read the man page for cp to see the difference.

Code:
# man cp

If that all fails, then substitute the cp for a find/cpio combination to copy your directory tree:

Code:
# cd /dir/dir/<top of tree to be copied>
# find . -depth -print|cpio -puvdm <target directory>

Note: In the above the <target directory> MUST already exist before the command is issued.

See if that does the job. Do let us all know the outcome.
This User Gave Thanks to hicksd8 For This Post:
# 6  
Old 02-06-2018
Under which user account did you run the script? If it was not root this might have been the problem.

Furthermore, to copy a (sub-)tree recursively it is generally better to use tar instead of cp -r:

Code:
cd /path/to/source ; tar -cf - * | (cd /path/to/target ; tar xf -)

will copy all files and directories in /path/to/source to /path/to/target AND it will preserve all filemodes and ownership properties.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 7  
Old 02-06-2018
Thanks everyone.. Its working now.
Code:
cp -R

not
Code:
cp -r

I'm not piping anything so I'm not sure why it works.. but it works.

I'll read up on tar anyway- I've never used it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying large files in a bash script stops execution

Hello, I'm new to this forum and like to first of all say hello to everyone. I've got a really annoying problem at the moment. I'm trying to rsync some files (about 200MB with one file of 120MB) from a Raspberry PI with raspbian to a debian server via rsync. This procedure is stored in a... (3 Replies)
Discussion started by: wex_storm
3 Replies

2. Shell Programming and Scripting

Mount fails (because remote machine is off) bash script stops

Hi, I'm trying to automate a couple of mounts. (I would do this in fstab, but the auto feature causes the virtual machine I'm running in to freeze when it boots up) If the machine I'm trying to connect to is OFF, I get the host unreachable error and then the bash script stops. The problem is... (3 Replies)
Discussion started by: jdilts
3 Replies

3. Shell Programming and Scripting

My script stops after logoff...why??

Hi' i am runing a script thats run with a loop...while loop true. when i exit the server..logon and again the script doenst run. its a bash script test.sh. i run it as: #./test.sh & what can be the priblem please? thanks alot (6 Replies)
Discussion started by: zigizag
6 Replies

4. Shell Programming and Scripting

My script stops working when using crontab

I have made a shell script(/bin/sh) that starts a perl script (that I haven't made my self) that's starts a ssh session. The ssh session uses a private/public key to login so no password is needed. The Perl script works perfect. But when I put it in a cronjob (crontab) the ssh connection asks... (6 Replies)
Discussion started by: splinter_cell
6 Replies

5. Shell Programming and Scripting

Script stops working after copying it

Hi all, When I cp a script, this section of the code stops reading from a file. if ; then while read dirtoclean do DIRSTOCLEAN=${DIRSTOCLEAN}' '$dirtoclean done < ${BASEDIR}test.conf fi ${DIRSTOCLEAN} doesn't return anything, even though it will work right before... (6 Replies)
Discussion started by: nicksantos1
6 Replies

6. Shell Programming and Scripting

Script with infinite loop stops after sometime

Hi I am working on a server that is set up and maintained by a third party. It seems whenever I run bash scripts in the background (with a &) with while loops in them they seem to me killed in around 2.5 hours. ( I am running them as a normal user with no special privileges ) . Is there a... (3 Replies)
Discussion started by: pkabali
3 Replies

7. Shell Programming and Scripting

cleartool - script stops after using setview

Hi Guys, See the below code. The command below the cleartool setview ITG_Automation is not executing. Could you please suggest. #!/bin/ksh echo $0 cleartool setview ITG_Automation echo $0 (3 Replies)
Discussion started by: ajincoep
3 Replies

8. Shell Programming and Scripting

Why My Script Stops After 1st Command

My script is very simple. It call isql and then echo a message. The problem is after the 1st command (isql), it stops so that the echo line never gets executed. Can anyone let me know what is wrong? #!/usr/bin/sh userid=xxxx server=xxxx db=xxxx pwd=xxxx isql -U ${userid} -S ${server}... (3 Replies)
Discussion started by: robbyls
3 Replies

9. Shell Programming and Scripting

Script stops running the remaining checks after becoming admin

Hi all, I encountered a problem where my script stops running the remaining checks after becoming an admin that is written within the script. For example: ========================================= #!/bin/sh check 1 # Runs successfully check 2 # Runs successfully /com/bin/admin #... (1 Reply)
Discussion started by: seanchew
1 Replies

10. OS X (Apple)

terminal script stops after script command :(.

Hello, i am trying to write a script for terminal for my mac that i may drag into the terminal and will excute the following command: script -akq Desktop/TerminalLogin/Cisco1Bob.txt telnet x.x.x.x the problem is that when i drag the text file to the terminal window the script stops after... (6 Replies)
Discussion started by: drdread
6 Replies
Login or Register to Ask a Question