Scp without writting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scp without writting
# 1  
Old 05-09-2006
Scp without overwritting

Hi,
i have a file (filename xyz.file) and i scp it daily to server B. B runs a job daily and remove it. A sends it at 9am, B removes it at 915am.

Now i have another server C, it also scp a file (xyz.file) to B. C will send to B at 930am and B will remove it at 10am.

My worry is if B fails to remove it at 915am, and when i scp from C at 930, it will overwrite the existing file.

(1) is there any way to scp without over writing?
(2) is there any command that i can use to check if the file still exists after 915 in B( the file sent from A) , i will not send the file at 930 from C.

It is not advisable to use another filename for the second scp due to business rules.
please advise.

Last edited by new2ss; 07-18-2006 at 05:54 AM..
# 2  
Old 05-09-2006
If you can use rsh then how about running (from A):

Code:
command
status=$(rsh B "ls -l /somedirectory/xyz.file" 2>/dev/null | wc -l)

$status will have value of 0 is file doesn't exist or 1 if it does
# 3  
Old 05-10-2006
thanks for the suggestion, i'll try that out.

It worked! thank you very much.

Last edited by new2ss; 05-10-2006 at 04:06 AM..
# 4  
Old 05-15-2006
Hi,

Because i am executing the command in a perl script, i will be using the following line
Code:
system (rsh B "ls -l /somedirectory/xyz.file" 2>/dev/null | wc -l);

how can i get it to return the value to a variable in perl so that i can test the value of the variable?
# 5  
Old 05-15-2006
Instead of using system, use the ` (backticks) just like you do in a shell script.
Code:
$output=`rsh B "ls -l /somedirectory/xyz.file" 2>/dev/null | wc -l`;

# 6  
Old 07-18-2006
Hi all,

i realise option (2) was not feasible because it would cause a backlog if i cannot scp due to the existance of the unprocessed file.

how can i get the file over and append it into the unprocessed file?

I've tried to use this, will it prevent over writting?
Code:
system (/local/bin/ssh $host cat < $local \">>\" $Target")

i've also encoutered an error "/local/bin/ssh: No such file or directory". I think its the directory ( in italics) that is causing the error, how can i find out the correct directory of my machine?

Last edited by new2ss; 07-18-2006 at 05:58 AM..
# 7  
Old 07-18-2006
# which ssh
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to use scp?

How to copy multiple directories using single command on solaris 10 from server A to server B. I tried scp but its working only one directory at atime How to acheive this with simple and short solution????? (6 Replies)
Discussion started by: buzzme
6 Replies

2. Shell Programming and Scripting

SCP

Hi All, Please help on the below command scp -r 'directory name'inrvgo@IP:/export/home/muthu/prod_12-09-2010 I am trying to copy a directory from one server to another server using the above command but its displaing the error (missing destination file) but the diectory was there in the... (1 Reply)
Discussion started by: thelakbe
1 Replies

3. AIX

scp

1. how to move files in a directory using scp ? 2. how to move the entire directory ? 3. Will the file and the directory permissions affect scp usage? (1 Reply)
Discussion started by: samsungsamsung
1 Replies

4. Red Hat

scp with su

Hi Friends, I am trying to copy some files over the network in between my linux servers. I am using scp command for this. by default direct ssh root login is disabled on all of my linux servers. Normaly we used to login as a normal user and the su to th root user. unfortunately root user is... (1 Reply)
Discussion started by: arumon
1 Replies

5. Shell Programming and Scripting

writting a shell script to delete damage files

hi, I have 100 files say File1.mp3, File2.mp3 .......file100.mp3 i found that File1.mp3 to File50.mp3 are damaged. I want to delete the damaged files from the directory using sed with regex how can i do this. thanks (5 Replies)
Discussion started by: pchangba
5 Replies

6. Shell Programming and Scripting

Approach to writting a script

Hello all, I've just joined. I did a google search and your site came up, I had a look and thought I'd like to become a member. I'm from Ireland. I've written a few scripts before, but this new task has me foxed. I would like to figure out the best approach to achieving the following ... (15 Replies)
Discussion started by: Bloke
15 Replies

7. Shell Programming and Scripting

scp

hi can any one pls tell me how to copy a file from a remote host to the same remote host with a timestamp, i need to use only scp. thnks (4 Replies)
Discussion started by: bkan77
4 Replies

8. UNIX for Advanced & Expert Users

Scp

I am trying to transfer a 10g files using scp, but I am getting timeout errors is there anywhere that I can modify a config file or something to increase the time. (4 Replies)
Discussion started by: rbizzell
4 Replies

9. Shell Programming and Scripting

Writting to multiple file

Hi!, My script generates a lot of files while running.. The same output at any point may be diercted to some of them.. if I have 4 files file1 file2 file3 file4, echo "output" to file1 file2 file3 file4 Any ideas on how to do it?? (2 Replies)
Discussion started by: jyotipg
2 Replies
Login or Register to Ask a Question