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

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:

+ 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

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