1755645 Members
2997 Online
108837 Solutions
New Discussion юеВ

ftp script help

 
SOLVED
Go to solution
lawrenzo
Trusted Contributor

ftp script help

Hello,

I am writing an ftp script for the first time .......

I am familiar with the syntax ie

ftp -v -i -n <
hello
7 REPLIES 7
Peter Godron
Honored Contributor
Solution

Re: ftp script help

Chris,
the way I see it:

1. To check you have all the info of the file, get a list of the directory you are ftping, then ftp the files and compare the size of the files against the dir listing.

That assumes you can't get the source system to generate an index file with checksum of all the individual files, which would act as a marker that all the files had been generated on the source - clear to start ftp.
You could then use the checksum file to compare checksums.

Header/trailer records could be an alternative.

2. use "get abc _abc"

then after comming out of the ftp part of the script move _abc to abc


What do you think ?
lawrenzo
Trusted Contributor

Re: ftp script help

good idea however I am putting the files to a windows box then moving to an archive dir on the unix box.

the files are _abc when ftp puts to the windows box then rename _abc abc on the windows box so another program can then transfer to a server else where.

on the unix box then mv the abc to /archive.

I have an idea where I list the files on the unix server and create a files.lst.

files ftp over then ftp the files.lst then run a program on the windows server to xref _abc with files.lst.

once verified mv files within files.lst to archive.

a bit of a mess but we are using an sftp server for transfering data to a company not associated with the company I work for.

is there a way I can reference files.lst so to ftp the files in that list?

Chris.
hello
Peter Godron
Honored Contributor

Re: ftp script help

Chris,
best way for referencing is to do a dynamic ftp script:
echo "ftp -v -i -n < ftper.sh
echo "username xxxxx xxxx" >>ftper.sh
# prefix each file with "get "
sed "1,$ s/^/get /" files.lst > files.dat
cat files.dat >> ftper.sh
echo "quit" >> ftper.sh
echo "!EOF" >> ftper.sh
chmod 777 ftper.sh
./ftper.sh
lawrenzo
Trusted Contributor

Re: ftp script help

ok Thanks Peter, I will give this a wizz and let you know how I got on!

Chris

<(+_+)>
hello
lawrenzo
Trusted Contributor

Re: ftp script help

one thing so I understand the syntax etc what does:

sed "1,$ s/^/get /" files.lst > files.dat

the "1,$" mean? I get the s/^ is the start of the line - does it mean from beginning to end of file?

cheers
hello
Peter Godron
Honored Contributor

Re: ftp script help

Chris,
yes, 1 to last line

Dennis Handly
Acclaimed Contributor

Re: ftp script help

>lawrenzo what does: the "1,$" mean?

You should probably remove it since that's the default. And you would probably understand it better. :-) (For vi/ex, you can use % for that.)