Hello everyone,
What I'm trying to do is figure out how to ftp a set of random files each day about 50 or so maybe more or less.
I have a folder on my server that gets about 1000 or so new files each day, each with today's date in the file name. We just want to take a sample each day for quality checks.
eg. testnumberssomethingelse20071121morenumbers
What I need to do is grab 50 random files for today's date and upload them via ftp. I have all the code for ftp and what not, I just don't know how to pick out 50 or so files out of 1000+ and direct them to my ftp process.
Here is my current script without randomization, which I've gather mostly from here.
Code:
#! /bin/ksh
stty -echo
#print -n Enter Password-
#read PASS
print
stty echo
exec 4>&1
HOST=iphere
USER=test123
DESTDIR=/
SOURCEDIR=/something1/something2
PASS=test123
cd $SOURCEDIR
ftp -nv >&4 2>&4 |&
print -p open $HOST
print -p user $USER $PASS
print -p binary
#print -p cd $DESTDIR
ls | while read filename ; do
[[ -f $filename ]] && print -p put $filename
done
print -p close
print -p bye
wait
exit 0