Need help in FTP script to archive


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in FTP script to archive
# 1  
Old 06-14-2017
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 09:26 AM..
# 2  
Old 06-14-2017
Try moving the cd $FTP_SRC_PATH line after the quote lines in the ftp script.
# 3  
Old 06-14-2017
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:
Mod Comment 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 04:21 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies

2. UNIX for Dummies Questions & Answers

Remote FTP Backup -Tar archive+ encrypt+ split to a remote ftp

I have a huge directoy(200+ gb) for backup. I want upload the tar file(split files) simultaneous to a remote ftp. (pipeline, stdout, stdin etc.) I don't want write a data to local hdd. I have a ssd hdd. thanks. this code doesn't work.( yes i know the problem is split command!) tar cvzf -... (8 Replies)
Discussion started by: tara123
8 Replies

3. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

4. Shell Programming and Scripting

How to wait for tar to finish before sending the archive through ftp?

Hey all, I want to automate tarring a directory then using ftp to transfer the files over. I was able to put the commands together but what I'm noticing is that only the very first file is being tarred and then transferred. tar cvpf new.backup sourceAbove is the command I'm using which works... (4 Replies)
Discussion started by: Keepcase
4 Replies

5. Shell Programming and Scripting

need help archive script

Hi all, I am new to linux and scripting so please forgive me. I need to create a script that will archive files but the max size of the archive need to be 500mb or under. I know about the archiving with parts but i want all the archives as individual archives. Can anyone point me in the correct... (7 Replies)
Discussion started by: craig0
7 Replies

6. Shell Programming and Scripting

Need some help with an archive script

I'm not sure how to solve the $month-1 thingy or the foreach sentence, so I need some help./* folders = folder1 folder2 folder3 folder4 folder5 */ month=`date +%m` if($month == 01) { prev_month = 12 } else { prev_month =... (7 Replies)
Discussion started by: JKMlol
7 Replies

7. Shell Programming and Scripting

ftp, archive, email and delete from shell script

Hello, I found the forum’s information very helpful and informative. I am relatively new to UNIX programming. I am researching how to write a UNIX shell script to ftp all files from specific host folder to a client server. Also need to archive all transferred files, send a message (email) if any... (4 Replies)
Discussion started by: Lenora2009
4 Replies

8. Shell Programming and Scripting

ftp a file after checking the versions not greater then 8 in archive directory

Hi , I want to write a FTP Script which checks the No of Vesions of the files in Archive Dir and if count >= 8 Delete the oldest file from the Archive Dir and if the count is <= 8 Move the file to the Archive Dir with a CurrentDate concatenation and FTP the file to the FTP directory and send... (1 Reply)
Discussion started by: kailash.jadhav
1 Replies

9. Shell Programming and Scripting

script help .. archive

Hi All We have a landing directory where source system puts files.There are variable number of files and the file names are also varying.Each files successful transmission is identified by a .done file.If file name is xyz.dat then the confirmation file will be xyz.dat.done. I want to... (1 Reply)
Discussion started by: dr46014
1 Replies

10. Shell Programming and Scripting

Archive script

hi guru, can advise how to construct a housekeeping script using perl for the following ? find /var/tmp/logs -name "si*" -type f -exec gzip -f {} \; find /var/tmp/logs -name "*.gz" -type f -exec mv -f {} /var/tmp/log \; I found out those are not working in shell at when put them on... (1 Reply)
Discussion started by: rauphelhunter
1 Replies
Login or Register to Ask a Question