1)I need to write a script which ftps 3 files to a unix box,
2)once the files are ftped i need to check the number of rows in each file and compare it with the data (no of rows) coming in a manifest file, if the number of rows in each file matches the data coming in manifest file, then i need to send a email saying ftp is successful.
3)These files come in with a timestamp I need to rename these files by removing the time stamp.
I am new to unix can anyone help me with this please.
Thanks in advance
Does it have to be ftp? Well, you can use wget with ftp and make it pretty script painless, as good as scp, just less secure and no compression option. That takes the pain out of #1. #2 is pretty simple, depending on the structure of the manifest file. wc -l will count your lines. What do you do for bad files? Renaming is no big deal, but what is the structure of the name before/after?
Hi
Thanks for you early reply,
Actually its SFTP.
here is the script i came up with to ftp and rename the file., i need to add the manifest and email logic to it...
Please find below he script....
#!/usr/bin/ksh
ftpFrom="/JANUS_IMS_health_Test/MarketRx"
ftpTo="/coe/informatica/v712_OMJ/OMJ_Proherant/SrcFiles"
host="Hostname.com"
user="aimran79"
echo "sftp start"
cd $ftpTo
sftp $user@$host <<EOF
cd /JANUS_IMS_health_Test/MarketRx
mget *.*
bye
EOF
for file in `ls *.csv`
do
mv $file `echo "$file" | sed 's/_[^_]*\././'`
done
echo "Program Ended Successfully"
Look into the ksh trimmers like ${#} and ${%%}, since "${file%_*}.extn" is like your sed. My memory mnemonic is pound # on the nose, get your % in the end. Double is aggressive wc, single is lazy wildcard. Saves fork, exec per.