delete a file
Hi
can someone help me delete a file on a remote server using shell scripting . |
common idea would be to use ssh with the delete command like
Code:
ssh [user]@[host] rm -f path/to/file |
thanx Zirias
it prompts for password , i dont want to have a passwordless ssh login how can i supply the password with this command i tried using expect and send command but it doesnt work |
Hmm, you'll probably want to use an ssh key. You can generate one for your script, make it have no passphrase and keep it secret by setting appropriate permissions on it.
See ssh-keygen(1). |
this will create a ssh login with out password which is not my requirement
i need to somehow pass the password alsong with the ssh command |
No it won't, as long as you keep THAT key secret. Passing the password is NOT a good idea, using a key is much more secure.
|
Hi,
Quote:
As already stated by zirias: Setting up a password-less ssh is the way to go. Much more secure. Hope this helps. |
i did want zirias suggested used the command
ssh [user]@[host] rm -f path/to/file now it gives me permission denied the file resides in /home/XYZ/t/txt |
Well that probably relates to filesystem permissions. Who is creating the file? Log in the machine interactively, check the permissions with ls -l. You need to add your ssh key to an account that actually HAS permissions for the file you want to delete AND the directory containing that file.
|
i logged and tried to delete it manually it gives the same permission denied , i checked the ownership group and permission it, owner itself cant delete the file how is this possible..
|
Hi,
Quote:
|
stat output
File: `aabackup.zip' Size: 14158138 Blocks: 27704 IO Block: 4096 regular file Device: 805h/2053d Inode: 50069506 Links: 1 Access: (0777/-rwxrwxrwx) Uid: ( 502/ francis) Gid: ( 502/ francis) Access: 2010-07-25 09:31:01.000000000 +0400 Modify: 2010-07-25 03:59:22.000000000 +0400 Change: 2010-07-25 13:18:04.000000000 +0400 ls -la output -rwxrwxrwx 1 francis francis 14158138 Jul 25 03:59 aabackup.zip |
Hi,
I asked for the output of ls -la /home/XYZ/t/, not ls -la /home/XYZ/t/txt PS: I'm off-line for a few hours, answer will take a while. |
Quote:
|
thanx solved the directoy had root permissions
|
All times are GMT -5. The time now is 03:48 AM. |