How to check the file locked or in use at FTP?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to check the file locked or in use at FTP?
# 1  
Old 06-16-2017
How to check the file locked or in use at FTP?

Hi Experts,

I am beginner to shell scripting, I have a archive script which will connect to the FTP server and archive the files from FTP source location to FTP archive location.

Now the problem here is, the script working for few files and not working for few.I am facing the below error (Files are in use or locked).My question is how to check whether the files are in USE or LOCKED? and if they are locked or in use, how to remove

Code:
HOST='xxxx'
USER='xxxx'
PASSWD='xxxx'
PORTNO='9999'

FILE_NAME=$1
FTP_SRC_PATH=$2
FTP_ARC_PATH=$3
CURR_PATH=`pwd`
#CURR_PATH='/Product/Asset/Source'

ftp -n $HOST $PORTNO <<ENDfilelst
cd $FTP_SRC_PATH
quote USER $USER
quote PASS $PASSWD
bin
prompt
lcd $CURR_PATH
cd $FTP_SRC_PATH
ls $FILE_NAME archivefilelist.txt
quit
ENDfilelst
cat archivefilelist.txt
cat archivefilelist.txt | rev | cut -d' ' -f1 | rev > tempfile
mv tempfile archivefilelist.txt

while read line
do
ftp -n $HOST $PORTNO <<ENDfilelst
quote USER $USER
quote PASS $PASSWD
bin
prompt
lcd $CURR_PATH
rename $FTP_SRC_PATH/$line $FTP_ARC_PATH/$line
quit
ENDfilelst
done < archivefilelist.txt


Error Line:
Code:
+ mv tempfile archivefilelist.txt
+ read line
+ ftp -n wmx-mft-test.xxxx.com 8121
Interactive mode off.
Local directory now /var/local/ei/etl/Scripts
File rename error. (bad path?  in use?  locked?)
+ read line
+ rm archivefilelist.txt

# 2  
Old 06-16-2017
Hello spidy,

A few questions first I'm afraid:-
  • What sort of size files are we considering? That may affect the plan.
  • Are there geographic/slow network issues to consider?
  • I know that you want to keep certain things secret, but you output (including host & port number) doesn't match your script.
  • Can you add -v to your failing ftp command and an ls $FTP_SRC_PATH/$line before you try to get the file?
I must say that the section with the cut is confusing me a little. Can I presume you want the last field of the line? Is the field length variable?


Hopefully something here will illustrate where the problem is and we can work on it.



Thanks, in advance,
Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

After Ftp'ing file to destination how to check the file if it is in correct ASCII and not corrupted

Hi Folks, While transferring file from FTP software like Filezilla the files gets corrupted. Is there any way I can check if the recently transferred file is in ASCII and not corrupted. I have tried using file -i filename command which does tell if the file character set is ASCII or binary... (6 Replies)
Discussion started by: Khan28
6 Replies

2. UNIX for Advanced & Expert Users

FTP user getting locked out automatically

I need help. I have a ftp user which is used by other system to transfer file to my system. But somehow my ftp user gets locked out due to invalid failed logins by some source system and causing lots of problems. Also i am aware that user password is not expiring rather it is getting locked due to... (5 Replies)
Discussion started by: sv0081493
5 Replies

3. Shell Programming and Scripting

FTP user getting locked out automatically

I need help. I have a ftp user which is used by other system to transfer file to my system. But somehow my ftp user gets locked out due to invalid failed logins by some source system and causing lots of problems. Also i am aware that user password is not expiring rather it is getting locked due to... (2 Replies)
Discussion started by: sv0081493
2 Replies

4. Shell Programming and Scripting

Check if file is locked otherwise gzip it

Dear community, I've a continuos tcpdump on redhat that close the dumped file every 100000 captured packets. To avoid disk full I would like to gzip the closed *.cap file. But how can I check if the file is currently opened by tcpdump and skip it from gzip? Thanks! EDIT: Just to post an... (9 Replies)
Discussion started by: Lord Spectre
9 Replies

5. Shell Programming and Scripting

FTP file check help

hello i need check if file_name exist on remote FTP or not the FTP is anonymous and doesnt require username/pass (3 Replies)
Discussion started by: mogabr
3 Replies

6. Shell Programming and Scripting

Check file, before FTP

:mad: Hi All, I have written a script, which will get the file from other server through FTP. It is working fine, but i want to add a code which should first check, if the file is available in the source system and then do FTP, once successfully completed, it should delete the file. Is... (4 Replies)
Discussion started by: Amit.Sagpariya
4 Replies

7. Shell Programming and Scripting

file check before FTP

Hi I use a shell script to transfer files from UNIX to Windows 2000 server before the FTP i need to check whether any files with the same name exists. If the files are already present it need not be FTPed else the file should be FTPed. Kindly help me. (2 Replies)
Discussion started by: Codesearcher
2 Replies

8. Shell Programming and Scripting

How check for a new file on a ftp-server

Hi there, I want to write a linux shellscript that checks a specific folder on a specific FTP-server whether there are new files or not. If there are new files I want to download them to a local directory (to gain access for an local application to these files). The problem is that the files I... (3 Replies)
Discussion started by: monstrous
3 Replies

9. UNIX for Advanced & Expert Users

Using FTP to check whether file is completely FTP... plz find the description below

Hi, We have some clients who will place huge files in to one of the remote server. And the shell script written in our local server to retrieve client files (using FTP) placed on one of the remote server of ours by clients. My question Is there any FTP command/script to check from my local... (1 Reply)
Discussion started by: nmsrao
1 Replies

10. Shell Programming and Scripting

How to check file size before and after FTP

I want to trasfer file from 1. Unix server A to server B 2. Unix server A to windows directory Is there a way to check the size before and after FTP. I want to check the size of the file in server A before FTP and in server B after FTP in case 1 In case 2 I want to check the size of... (1 Reply)
Discussion started by: i.scientist
1 Replies
Login or Register to Ask a Question