Running script on SFTP server, RMDIR and RM with wildcards


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Running script on SFTP server, RMDIR and RM with wildcards
# 1  
Old 10-08-2009
Error Running script on SFTP server, RMDIR and RM with wildcards

Im going insane trying to figure out what i consider a basic command on an SFTP server...

Im trying to download all files from a directory *done*
then remove all the files (and sometimes folders that contain files) i have downloaded on the remote directory...

the command i would normally use is rm -r *

Ive tried

rm -r *
rm *
rmdir *
rmdir -r *
rm -r * + rm * together
rmdir -r

im going insane... can someone put me out of my misery?
# 2  
Old 10-12-2009
can anyone help with this?

---------- Post updated at 04:36 AM ---------- Previous update was at 04:24 AM ----------

Can i change the config on the sftp (ubuntu) server to enable removal of directories that contain files?

Im looking inside /etc/ssh/sshd_config not sure its the right place, really need a hand with this.
# 3  
Old 10-12-2009
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.

---------- Post updated at 11:52 ---------- Previous update was at 11:44 ----------

Taking a look at man sftp, I see two commands that would match:
Code:
     rm path
             Delete remote file specified by path.

     rmdir path
             Remove remote directory specified by path.

Both take no arguments. 'rm', in this case is only for files, while 'rmdir' is only for empty directories. Both are completely independent of the usual shell commands you might know, but are instead a part of the SSH server (sftp module).

You can probably remove all the files you fetched using 'rm *' (assuming you have the rights to do so), but you'll have to descend into each directory you got, remove the files, and then remove the directory.

A faster, but less portable, way would be to fetch the files using sftp, and then delete them using
Code:
ssh user@host 'cd /path/for/files; rm -r *'

Be advised, though, using 'rm -r' without care can easily result in a damaged system, and should be avoided where ever possible.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Test if Remote server is up and running before SFTP'ing files (in batch mode)

Hello, In our Data Warehouse environment, before our batch SFTP jobs kick off to pull the files from remote servers, I would like to setup a pre-sftp job that would test if all the remote servers from where the files are being pulled, are up and running. If any one of the remote serer is... (2 Replies)
Discussion started by: Dippu
2 Replies

2. Shell Programming and Scripting

Help with running script at sftp

Hello All, I am trying to run a sftp batch script (.conf) file from a shell script. I wanted to remove a file from sftp if it exists else it should ignore removing and continue with other commands in .conf file. I am not able to put logic in .conf file.Any idea how that can be achieved. ... (2 Replies)
Discussion started by: sp92
2 Replies

3. Shell Programming and Scripting

How to Append the output of a script running in remote server to a file in local server?

Hi guys, So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies

4. Shell Programming and Scripting

Needed SFTP script from windows to UNIX server and from UNIX to windows server(reverse SFTP)

hi guys, i need a script to sftp the file from windows to unix server ....(before that i have to check whether the file exists in the windows server or not and again i have to reverse sftp the files from unix to windows server..... regards, Vasa Saikumar. (13 Replies)
Discussion started by: hemanthsaikumar
13 Replies

5. Solaris

Script to get files from remote server to local server through sftp without prompting for password

Hi, I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script. Can anyone help me in automating the script such that it... (3 Replies)
Discussion started by: ssk250
3 Replies

6. UNIX for Dummies Questions & Answers

Transfer file from server B to server C and running the script on server A

I have 3 servers A, B, C and server B is having some files in /u01/soa/ directory, these files i want to copy to server C, and i want to run the script from server A. Script(Server A) --> Files at Server B (Source server) --> Copy the files to Server C(Target Server). We dont have RSA key... (4 Replies)
Discussion started by: kiran_j
4 Replies

7. Shell Programming and Scripting

Sftp script for dev server to client server

hi, i am new to unix, cuold u send some sftp acripts to send files to dev server to clint server, (1 Reply)
Discussion started by: Koti.annam
1 Replies

8. UNIX for Dummies Questions & Answers

sftp output is different when running manually/script

When I manually run a sftp to a remote server I receive the following output on he screen; Uploading filename to /inbound/xxxxxxx_Folder_1/filename filename 100% 50 0.1KB/s ... (1 Reply)
Discussion started by: rugggy
1 Replies

9. Shell Programming and Scripting

sftp output is different when running manually/script

When I manually sftp a file to a remote server I get the following output on the screen; Uploading filename to /inbound/xxxxxxx_Folder_1/filename filename 100% 50 0.1KB/s 00:00 When I run the commands from within a shell script I do not get the "filename ... (0 Replies)
Discussion started by: rugggy
0 Replies
Login or Register to Ask a Question