Sponsored Content
Top Forums UNIX for Advanced & Expert Users SFTP - Overwrite [Put -P <file>] option Post 302407857 by felipe.vinturin on Friday 26th of March 2010 04:37:19 PM
Old 03-26-2010
Question SFTP - Overwrite [Put -P <file>] option

Hi All Experts,

I hope you are all ok! Smilie

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 what sftp's man page says about it: "If the -P flag is specified, then the file's full permission and access time are copied too."

What I need is to overwrite the "-P" option in the server side, I mean, I need to change the access time to the current time, is like the client not used the "-P" option.

Is there a way to do it? Smilie

Below there is an example(of course you know it):
Code:
$ sftp USER@SERVER
Connecting to SERVER...
Password:
sftp> put -P FILE.log.2009-10-21
Uploading FILE.log.2009-10-21 to /PATH_TO_FILE/FILE.log.2009-10-21
FILE.log.2009-10-21                                                                                                                      100%  855     0.8KB/s   00:00
sftp> ls -l
-rwxrwxrwx    1 USER   GRP           855 Oct 21 12:46 FILE.log.2009-10-21
sftp> rename FILE.log.2009-10-21 FILE.log.2009-10-21.keep
sftp> ls -l
-rwxrwxrwx    1 USER   GRP           855 Oct 21 12:46 FILE.log.2009-10-21.keep
sftp> put FILE.log.2009-10-21
Uploading FILE.log.2009-10-21 to /PATH_TO_FILE/FILE.log.2009-10-21
FILE.log.2009-10-21                                                                                                                      100%  855     0.8KB/s   00:00
sftp> ls -l
-rwxr-xr-x    1 USER   GRP           855 Mar 26 17:23 FILE.log.2009-10-21
-rwxrwxrwx    1 USER   GRP           855 Oct 21 12:46 FILE.log.2009-10-21.keep
sftp>

As you saw, it kept the access time when I used the -P option, and changed the access time when I did not use it.

Again, what I need is whenever the client uses the -P option, the server ignores it and changes the access time.

That's it!

Thanks for your attention and help!

Regards!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP - 'put' doing an 'mput'

Hi guys, I'm having a problem with F-Secure Unix. When I try a simple command; sftp> put local.test remote.test I expect that the local file local.test would be copied to the remote file remote.test However sftp is attempting to copy local.test & remote.test from the local machine, as if... (2 Replies)
Discussion started by: b0bbins
2 Replies

2. UNIX for Advanced & Expert Users

how to prevent overwrite particular config file when using rpm --replacefile option

Helo I have already installed manbase - 4.0.0.0.15 Now I m installing newver version of the same rpm using rpm -iv -replacefiles manbase -4.0.0.0.16 But using this option my important config files is overwrite. now I want that using first check whethere config file is there or not.... (0 Replies)
Discussion started by: amitpansuria
0 Replies

3. Shell Programming and Scripting

sftp -b option

Hi, what does -b option do in sftp batch mode..?:confused: (1 Reply)
Discussion started by: rahulsxn660
1 Replies

4. Shell Programming and Scripting

SFTP bash put/get/rm check

Hello, i'm doing something like that #!/bin/sh sftp 172.18.255.140 <<End-Of-Session >> /usr/batch/logsftp.txt user batch ascii lcd /usr/batch get olaola.txt bye End-Of-Session   if then echo MAL >> /usr/batch/logsftp.txt echo $? >> /usr/batch/logsftp.txt exit $? else echo... (16 Replies)
Discussion started by: dexposit
16 Replies

5. Shell Programming and Scripting

SFTP PUT

Hi, ServerA (SFTP server) ServerB (SFTP client) ServerB:> sftp user@ServerA ServerB:> put sample.txt ServerB:> get sample2.txt My question is that which machine will encrypt the sample.txt and sample2.txt files. Thanks (8 Replies)
Discussion started by: Arpit Narula
8 Replies

6. Shell Programming and Scripting

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... (3 Replies)
Discussion started by: Little
3 Replies

7. Shell Programming and Scripting

./CARE_SM_SFTP.sh[27]: put: not found error while doing sftp

Hi, I am getting the below error while doing sftp in a script file but the same is getting executed when i run from command prompt ./CARE_SM2_SFTP.sh: put: not found Code :- sftp ${USER_ID}@${FTPHOST4}:/opt/path put <Filename with path> chmod 777 <FileName with Path>... (2 Replies)
Discussion started by: satishmallidi
2 Replies

8. Shell Programming and Scripting

SFTP batch not renaming file with "put"

I have a .ksh script that creates an sftp batch file and runs it through sftp. It works except for one thing. If I try to "put" to a different name, it doesn't use the specified remote name...it still "puts" the original local name. I've tried both of these, and neither work...it will always... (4 Replies)
Discussion started by: dbiggied
4 Replies

9. Red Hat

SFTP with limit(l) option

Hi, I have sftp installed in some of my corporate servers (test and production). However, I notice that it does not have the limit(l) option for bandwidth limit option. Why is this? Is it because sftp was not installed with other necessary packages? How do I make sftp available with the... (4 Replies)
Discussion started by: anaigini45
4 Replies

10. Linux

Put -r is not working in SFTP

Hi Folks, I am trying to copy a directory along with sub-directories to SFTP server. I have connected to SFTP and tried to run the below command: sftp> get -r abc/* It is throwing the error Invalid flag -r Can you please let me know the ways to copy a directory from Local to SFTP ... (1 Reply)
Discussion started by: kirans.229
1 Replies
sftp-server(1M) 					  System Administration Commands					   sftp-server(1M)

NAME
sftp-server - SFTP server subsystem SYNOPSIS
/usr/lib/ssh/sftp-server DESCRIPTION
sftp-server implements the server side of the SSH File Transfer Protocol as defined in the IETF draft-ietf-secsh-filexfer. sftp-server is a subsystem for sshd(1M) and must not be run directly. There are no options or config settings. To enable the sftp-server subsystem for sshd add the following to /etc/ssh/sshd_config: Subsystem sftp /usr/lib/ssh/sftp-server See sshd_config(4) for a description of the format and contents of that file. There is no relationship between the protocol used by sftp-server and the FTP protocol (RFC 959) provided by in.ftpd. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. FILES
/usr/lib/sftp-server ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWsshdu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
sftp(1), ssh(1), ssh-add(1), ssh-keygen(1), sshd(1M), sshd_config(4), attributes(5) To view license terms, attribution, and copyright for OpenSSH, the default path is /var/sadm/pkg/SUNWsshdr/install/copyright. If the Solaris operating environment has been installed anywhere other than the default, modify the given path to access the file at the installed location. AUTHOR
Markus Friedl SunOS 5.10 30 Jul 2003 sftp-server(1M)
All times are GMT -4. The time now is 10:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy