Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

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

Shell Programming and Scripting


Tags
ftp, shell script

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-16-2017
spidy spidy is offline
Registered User
 
Join Date: May 2017
Last Activity: 16 June 2017, 3:34 AM EDT
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
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

Sponsored Links
    #2  
Old Unix and Linux 06-16-2017
rbatte1 rbatte1 is offline Forum Staff  
Root armed
 
Join Date: Jun 2007
Last Activity: 22 August 2017, 9:50 AM EDT
Location: Lancashire, UK
Posts: 3,214
Thanks: 1,370
Thanked 616 Times in 557 Posts
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
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to kill the process when the file is locked? Ram Kumar_BE Shell Programming and Scripting 10 10-07-2015 05:35 AM
Check if file is locked otherwise gzip it Lord Spectre Shell Programming and Scripting 9 03-16-2013 05:26 PM
find locked files, print file path, unlock file alternapop UNIX for Dummies Questions & Answers 0 04-14-2009 08:09 PM
checking whether a file is locked hariza Shell Programming and Scripting 2 09-19-2008 03:09 AM
How can a file be locked for a certain time? darthur UNIX for Dummies Questions & Answers 6 12-09-2003 10:35 AM



All times are GMT -4. The time now is 11:06 AM.