How to overwrite a file by transferring the file using sftp?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to overwrite a file by transferring the file using sftp?
# 1  
Old 06-27-2013
How to overwrite a file by transferring the file using sftp?

hi,

i am using sftp to transfer files between two servers,

if i connect to a remote server using sftp n moves a file say "S123.txt" to the remote server, it moves successfully, but when i try to execute the same sftp script to move the same files to the same remote server, the old file is not replaced with the new one. i want the new file to overwrite the old file. how can i do this.. is there a command in sftp which forcely overwrites the old file.
# 2  
Old 06-27-2013
If the filename is the same, it is usually overwritten with the new file, just as you tried it on the command line.
Do you get a message when it can't be overwritten? Do you write any log output from your script?
# 3  
Old 06-28-2013
no i dint get any such message in the log file. but the arrival time of the file was not changed so i thought its the old file.
# 4  
Old 06-28-2013
1. confirm that the time stamp of the new file on the local server is different from the time stamp of the file at the remote server ... ls -l $local_file and ls -l $remote_file

2. if time stamps are the same, touch $local_file and confirm $local_file time stamp changed with ls -l $local_file ...

3. run sftp job to transfer $local_file to remote server ...

4. confirm time stamps again ...

if time stamps are now the same, sftp transfer overwrite is successful ...

if time stamps are still different, check logs on remote server for any issues ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can we overcome Broken pipe error during scp,SFTP,Rsync while transferring big files.?

Hello All, Hope all are doing well. We use scp (some times sftp and rsync also) for transferring big files (around 2GB each ) from 1 Network to another Network. The Issues which we face :- During transfer some times( Once in 1 week (or twice)) , the speed of transfer gets down to 30 kb/s,... (2 Replies)
Discussion started by: Upendra Bhushan
2 Replies

2. Shell Programming and Scripting

Overwrite file every day

Hi Friends, I have written a script to capture system performance every hour and redirected to output file. How to overwrite the file every next day? Thanks Suresh (4 Replies)
Discussion started by: suresh3566
4 Replies

3. Shell Programming and Scripting

Is it possible to create 10GB file in Linux and transferring the file to other remote server

Hi folks, Is it possible to create 10GB file in linux and transferring the file to other remote server? Regards, J (3 Replies)
Discussion started by: scriptscript
3 Replies

4. UNIX for Dummies Questions & Answers

Transferring a file from one UNIX server to another

Hi, Is there a way to transfer a file from one unix server from another without entering the login credentials. I know scp and other commands but it prompts the username/password. However in my script i have a file, who i need to send to another unix server where the content of that file will... (4 Replies)
Discussion started by: gopajitmalakar
4 Replies

5. Shell Programming and Scripting

Avoiding file overwrite during file transfer using scp

Hi, I have written a small script to transfer a file from one unix server to other using scp command which is working fine. As I know with scp, if any file with the same name is already present on destination server, it would get overwritten without any notification to user. Could anyone help me... (14 Replies)
Discussion started by: dsa
14 Replies

6. Solaris

File transferring and checking in Solaris 10

Hi all. I'm trying to write a script in bash or perl which can let server transfer files to all its clients, like broadcast. After then, it can generate a log file showing which client's transfer is successful and which is failed. The OS is Solaris 10 u8, could anyone provide any idea please?... (2 Replies)
Discussion started by: gundamwings
2 Replies

7. UNIX for Advanced & Expert Users

SFTP - Overwrite [Put -P <file>] option

Hi All Experts, I hope you are all ok! :D My question is simple but I was not able to find an answer in the internet, and that's why I am here! My question is: when I sftp to a server and use "put -P" option to put a file, it keeps the file's full permission and access time. Check below... (5 Replies)
Discussion started by: felipe.vinturin
5 Replies

8. Red Hat

Can't overwrite a file into a mount file

Hi, I have mounted an /mnt/shared folder from a Dlink box into RedHat 5 box. mount -t cifs -rw -o username=root,password=blablabla //10.2.36.109/Volume_1 /mnt/shared After that it does not allow me to overwrite any flat files, just create new files, even for files which are as... (1 Reply)
Discussion started by: Ricardo Olguin
1 Replies

9. Shell Programming and Scripting

Transferring file from Windows server...

Hi, I want to transfer html files from windows server to unix server. Those files also have to be assigned proper permissions. Can u people suggest any ideas for this scenario? Regards, http://www.unix.com/images/smilies/thumb.gifSanthosh (1 Reply)
Discussion started by: Santhosh_Ind
1 Replies

10. Shell Programming and Scripting

Error transferring large file using sftp protocol

Hello All, I am not able to transfer large file completely (more than 60 MB) through automated SFTP script. It transfers only the partial file (approximately 55 MB) and it stops. I use "expect" command to transfer file in a automatic mode through script. The file transfer rate i get is around... (0 Replies)
Discussion started by: prashant.patel
0 Replies
Login or Register to Ask a Question