SFTP to delete remote file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers SFTP to delete remote file
# 1  
Old 11-13-2014
SFTP to delete remote file

Hi guys
In this scenario, i have been able to transfer the file from a remote server to my local server, but how to delete the file from remote server once its copied. I am using this command
Code:
 MYFILE=/tmp/MyFiLe.$$
echo rm FROM_DIR/K* >$MYFILE

then
Code:
sftp -b $MYFILE
rm -f $MYFILE

and I have created a file called MyFiLe in /tmp with contents
Code:
rm -f xxxxx@33232.212431:/K*

But it ain't working

Last edited by Don Cragun; 11-13-2014 at 04:34 AM.. Reason: Add CODE tags.
# 2  
Old 11-13-2014
Please use code tags as required by forum rules!

"But it ain't working" is NOT something that we can base an error analysis on.

From looking at your post, I'd suggest you supply the authentication credentials to the sftp command itself and remove them from the batch file.
And, I'm not sure sftp's rm will accept the -f option.
And, shouldn't FROM_DIR be expanded in the echo command?
And, make sure the * in the echo command is escaped, otherwise it could be expanded to fitting file names.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

SFTP file check through a remote host

Hi all, posting my first time, hope not breaking posting rules with it, if yes, let me know. I'm trying to build a script to check a file in an sftp server through a remote server. The intention is to check the file in a sftp host, and if the file is found or not, it should send an email.... (4 Replies)
Discussion started by: MrShinyPants
4 Replies

2. Shell Programming and Scripting

SFTP problem......File not getting from Remote server

Hi, We are using one unix script which is using sftp command and connect to remote server and get some file form remote server. some time after running this script we are not getting any file . Could you please tell us detailed validation that is there any problem with... (6 Replies)
Discussion started by: maheshkumar93@g
6 Replies

3. UNIX for Dummies Questions & Answers

Find the latest file on remote sftp

Hi All, I need your help in finding the latest files in remote sftp and get those files to local server and process them. Please let me know I appreciate your valuable inputs. Thanks raj (7 Replies)
Discussion started by: rajeevm
7 Replies

4. Red Hat

Chroot sftp users, remote sftp login shows wrong timestamp on files

Hello, I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration. #pwd... (8 Replies)
Discussion started by: bobby320
8 Replies

5. UNIX for Dummies Questions & Answers

File Listing from remote to loca directory using SFTP

Hello, Using ftp i was able to get a directory listing to local directory. ftp - i <host_name> ftp <user> ftp <password> dir <dir> 200 PORT command successful 150 Opening ASCII mode data connection for file list -rw-rw-r-- 1 <uuu> <kkk> 160384 Apr 13 19:38 walmart.txt 226... (5 Replies)
Discussion started by: pavan_test
5 Replies

6. Shell Programming and Scripting

SFTP - Get size of file on remote server

Hi, I have a requirement where I need to do SFTP connection to remote server, get the size of the file on remote server and depending on the size, i need to get the file onto local server. Is there any command in SFTP to get the size of the file. I found one in FTP but not in SFTP (2 Replies)
Discussion started by: forums123456
2 Replies

7. Shell Programming and Scripting

Sftp- file not present in the remote location

I'm able to connect to the remote server (server_name). But when i'm transferring the files, its getting transferred. But the file is not there in the remote location. I tried with a zero byte and 5 byte file sftp6 -P <port-no> --password=file:///<file having the pwd>... (1 Reply)
Discussion started by: help_scr_seeker
1 Replies

8. Shell Programming and Scripting

check for file existence on remote machine using sftp

Hi all, I am a beginner to shell script.Can any one please help me on the below requirement I need to check whether the file (called 3Com_Files_Delivered.txt) exists on the remote mechaine or not? if so i need to copy all the files from there to my local mechaine.Especially i am... (7 Replies)
Discussion started by: narasimha123
7 Replies

9. Shell Programming and Scripting

Checking the file in remote server using SFTP

Hello, I would appreciate if any one can help me on this. The below script start running at 12:30AM. Every 5 min, i go and check the remote site. If i see filewatch.txt over there, then i need to call another shell script and load the data into database. If i don't see that file, then i have to... (2 Replies)
Discussion started by: govindts
2 Replies

10. Shell Programming and Scripting

creating a file on remote directory using sftp

Hi, My requirement is to sftp a file from one server to another.After the file is completely transferrred, i should be able to create a text(dummy) file on the remote directory. How could this be accomplished. Any suggestions? (1 Reply)
Discussion started by: borncrazy
1 Replies
Login or Register to Ask a Question