Need Help: Delete a file by Shell Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need Help: Delete a file by Shell Script
# 1  
Old 07-07-2005
Question Need Help: Delete a file by Shell Script

Need some help here.

We FTP out files to another server hourly. But before we can FTP to the other server. That server should send our server a "confirmation file" to tell us that they're ready to receive data. If they don't send the confirmation file, the files on our server should just stay until the next confirmation file. After sending the files to the other server, our script is supposed to delete the "confirmation file".

A script (with .scr filename) runs a shell script (with .sh filename). The shell script is the one which is supposed to delete the "confirmation file" after FTPing the files to the other server. Our problem right now is that the file that's supposed to be FTPed to the server is successfully FTPed BUT the "confirmation file" does not get deleted in the directory.

Any ideas on why a file does not get deleted by a shell script?
# 2  
Old 07-07-2005
Post that part of the script which is supposed to do the deleting.

Are you using mdelete or delete to delete the file on the remote machine ?

Also, you might not have the delete permissions on that remote machine. A write permission does not mean you have delete permission as well.

Vino
# 3  
Old 07-10-2005
how do i know if the user of the script has delete permission and not just write permission?


Here's the part of the script which should have deleted it?
rm root directory/directory/file
# 4  
Old 07-10-2005
Quote:
Originally Posted by r3edi
how do i know if the user of the script has delete permission and not just write permission?

Here's the part of the script which should have deleted it?
rm root directory/directory/file
You cant just rm a remote file on an ftp server. You need to use the delete command.

I am not sure, how you can set the delete permissions (via command line) for a user.

I use Cerberus FTP Server, and since it has an UI, I can set the required permissions for different user.

Vino
# 5  
Old 07-11-2005
What if the file that needs to be deleted is in the same server as the script? I still can't use rm ?

It's actually an EDI Gentran UNIX server.
# 6  
Old 07-11-2005
Once you are inside an ftp session, issue help

That will show you the commands that you can give at the ftp prompt.

Again, if you are inside an ftp session, then you could try this to remove a local file

Code:
ftp> !rm sample.txt

That should remove the sample.txt on your local machine

Vino

Last edited by vino; 07-11-2005 at 08:19 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to check a file and delete old files

Hello, I needed help with a shell script where in it checks if a file exists under a directory and also checks the age of the file and delete it if it is older than 3 weeks. thanks (10 Replies)
Discussion started by: hasn318
10 Replies

2. Red Hat

Need Script to ZIP/SAVE & then DELETE Log file & DELETE ZIPS older than 12 months

ENVIROMENT Linux: Fedora Core release 1 (Yarrow) iPlanet: iPlanet-WebServer-Enterprise/6.0SP1 Log Path: /usr/iplanet/servers/https-company/logs I have iPlanet log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I... (7 Replies)
Discussion started by: zachs
7 Replies

3. Shell Programming and Scripting

delete only particular file in directory shell script

Hi, what function do we use to delete only particular file that we want in directory shell script for example I want only to delete test.txt in directory how to do it ? in sh Thank (1 Reply)
Discussion started by: guidely
1 Replies

4. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

5. Shell Programming and Scripting

Shell script for searching a record,copy to a file and then delete it

Hi, I have a requirement in hand: I have a file with millions of records say file 1.I have another file, say file 2 which has 2000 records in it. The requirement is to read file2 , and remove the read record from file 1 and move i to a seperate file, file 3. For eg: Read file 2, get the... (5 Replies)
Discussion started by: kumara2010
5 Replies

6. Shell Programming and Scripting

Need Shell Script to delete lines in a file

Hi All, I have a file with 3 columns (Bank Name, Account Number and Amount). My requirement, I need to delete lines using Unix Shell script: 1. Which are having Alphanumeric characters in Account Number (eg. Line3). 2. Which are having 0.00 in amount. (eg. Line4) 3. And also I need to... (4 Replies)
Discussion started by: phani333
4 Replies

7. Shell Programming and Scripting

Delete content of file 1 in file 2 with shell script

OK, best is I explain what the operating enviroment is. Linux, but Motomagx. It is a Linux operated mobile phone, Motorola V8. I am writting a shell script, but got stuck. I have to delete the complete content of file 1 in file 2. I have attached the 2 files. You can see that the content of... (2 Replies)
Discussion started by: rasputin007
2 Replies

8. Shell Programming and Scripting

shell script for delete old files

i want to delete all the files in my directory except the latest one. i need to do this from shell script. say i have a.txt - latest file b.txt, c.txt.. it should delete all the files except a.txt? (4 Replies)
Discussion started by: krishnarao
4 Replies

9. Shell Programming and Scripting

shell script to edit file and delete entry

Can anyone provide me a shell script to edit a xml file and delete one entry. To do manually i can edit(vi editor) the file and 'dd' will delete the file.But I wiluld to know if I can do with a script. Thanks in advance Tannu (6 Replies)
Discussion started by: tannu
6 Replies

10. UNIX for Dummies Questions & Answers

Shell Script --- Delete ORA error from data file

Hi All, I have to make the following changes in shell script: When the data file is being created, an “ORA” error occurs in it. I have to remove this ORA error from data file and put it in log file. I am “ -n grip command” to find the ORA error and get the line number, How do I delete it... (1 Reply)
Discussion started by: sk005
1 Replies
Login or Register to Ask a Question