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.

Need help in FTP script to archive

Shell Programming and Scripting


Tags
archive, ftp file, shell script

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-14-2017
spidy spidy is offline
Registered User
 
Join Date: May 2017
Last Activity: 19 September 2017, 12:14 PM EDT
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
Need help in FTP script to archive

Hi Guys,

I am unable to archive the FTP files from FTP source path to FTP archive path.Currently i am running this script from the Local server. Can someone help me here.
Code:

Code:
#!/bin/ksh
set -x
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

I am getting below error


Code:
+ ftp -n wmx-mft-test.avnet.com 8121
Command not recognized or allowed.
Interactive mode off.
Local directory now /var/local/ei/etl/Scripts
+ cat archivefilelist.txt
+ cat archivefilelist.txt
+ rev
+ cut '-d ' -f1
+ rev
+ mv tempfile archivefilelist.txt
+ read line
+ rm archivefilelist.txt


Last edited by jim mcnamara; 06-14-2017 at 08:26 AM..
Sponsored Links
    #2  
Old Unix and Linux 06-14-2017
rdrtx1 rdrtx1 is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 23 October 2017, 6:55 PM EDT
Location: Houston, Texas, USA
Posts: 971
Thanks: 0
Thanked 332 Times in 314 Posts
Try moving the cd $FTP_SRC_PATH line after the quote lines in the ftp script.
Sponsored Links
    #3  
Old Unix and Linux 06-14-2017
spidy spidy is offline
Registered User
 
Join Date: May 2017
Last Activity: 19 September 2017, 12:14 PM EDT
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
Still facing the error in ftp archive script

Try moving the cd $FTP_SRC_PATH line after the
quote lines in the ftp script.

I am still facing the same error.Can someone help me here

Output Error:

Code:
+ FTP_SRC_PATH=/Product/Asset/Source
+ FTP_ARC_PATH=/Product/Archive
++ pwd
+ CURR_PATH=/var/local/ei/etl/Scripts
+ ftp -n wmx-mft-test.avnet.com 8121
?Invalid command
Interactive mode off.
Local directory now /var/local/ei/etl/Scripts
+ cat archivefilelist.txt
+ cat archivefilelist.txt
+ rev
+ cut '-d ' -f1
+ rev
+ mv tempfile archivefilelist.txt
+ read line
+ rm archivefilelist.txt

Moderator's Comments:
Need help in FTP script to archive Please use CODE tags when displaying sample input, sample output, and code segments (as required by forum rules).

Last edited by Don Cragun; 06-14-2017 at 03:21 PM..
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
Shell script to call Oracle archive backup script when file system reaches threshold value sasikanthdba Shell Programming and Scripting 4 10-17-2013 09:51 AM
need help archive script craig0 Shell Programming and Scripting 7 08-16-2010 05:05 PM
Need some help with an archive script JKMlol Shell Programming and Scripting 7 04-26-2010 11:32 PM
script help .. archive dr46014 Shell Programming and Scripting 1 04-28-2009 10:59 AM
Archive script rauphelhunter Shell Programming and Scripting 1 04-14-2009 09:39 AM



All times are GMT -4. The time now is 01:45 AM.