scan directory

The script should
_scan a specific directory
_If a file name is like one provided, then run the command to send the file via CFT
The name should be picked from a list. The current list is :
BENEFI.TXT,DPTERM.TXT,PROFIL.TXT,CLIENT.TXT,COABON.TXT,AUTTFI.TXT,CARTES.TXT,IMPMCF.TXT,AUTINT.TXT,MESSAG.TXT,RVLCPT,COMPTE.TXT
Remark : if there are several files selected, the files should be renamed and sent one after the other
Ie : the folder contains 2 files MESSAG.TXT.200812191456 and MESSAG.TXT.200812191105 which are like MESSAG.TXT* . Those 2 files should be renamed to MESSAG.TXTand sent one after the other
_rename the file to prefix it with yyyymmddhhmm and move it to an archived folder

CFT is working in asynchronous mode : if you rename your 2 files MESSAGE.TXT.xxx and MESSAGE.TXT.yyy to MESSAGE.TXT you'll overwrite the first one !

Give me the PART name and the IDF used, and I'll help you. :slight_smile:

i first want to deal with the files selection.
i create a file "files_list.txt" wich contains the files to be sent. my problem now is to see if the file exists two times (example:CLIENT.TXT.565656 and CLIENT.TXT.686868 and renaming them). here is my code.
can you help me please?

for MYFILE in `awk '{ print $1 }' files_list.txt`
do
find ./ascii -name $MYFILE* -print>>dir_list.txt
echo "Ok"
done

PART is SABDE and idf is %%e

Could you please say me if, on the side of the partner SABDE he will exploit the &NFNAME symbolic variable of CFT ?

Did you define a CFTSEND for your IDF "%%E" (strange id :confused:) ?

Waiting for your answer. :b:

yes. he will exploit the &NFNAME symbolic variable of CFT.
no, i didn't define CFTSEND for IDF "%%E"

Goldorekk, don't abandon me

Sorry, I didn't have any time to answer you.
I will give you a solution during the week-end (full of work today too).

Don't worry :wink:

ok Goldorakk. i'm waiting.

ls ./ascii -r>dir_list.txt
for MYFILE in `awk '{ print $1 }' files_list.txt`
do
for MYDIRFILE in `awk '{ print $1 }' dir_list.txt`
do
#if [[ $MYFILE = $MYDIRFILE ]]OB
if expr "$MYDIRFILE" : ".*$MYFILE" != 0
then
if [[ $MYFILE != $MYDIRFILE ]]
then
mv ./ascii/$MYDIRFILE ./ascii/$MYFILE
fi
echo "Preparing to send file $MYDIRFILE"
fi
done
done

---------------------
this is what i did to collect the files tobe transfered.
my proble m now is to send the files with CFT.
Can u help me ?
pourrais-tu m'aider ?
ich bin .... ? :wink:

Well you have at least minimum 2 solutions.
But I'm full of work and I have to take time to explain you the possible solutions.
Please wait this evenig (in France) for my answer.

Sorry for the delay.

Well, to send a file with CFT, you must have first the good environment with path to CFT executables and other environment variables like theses :

$ env | grep CFT
CFTACNT=/home/cft/fillog/cft_acnt
CFTACNTA=/home/cft/fillog/cft_acnta
CFTCATA=/home/cft/fildat/cft_cata
CFTCOM=/home/cft/fildat/cft_com
CFTDIRADX=/home/cft/filadx
CFTDIRAPI=/home/cft/filapi
CFTDIRDAT=/home/cft/fildat
CFTDIREXE=/home/cft/filexe
CFTDIREXI=/home/cft/filexit
CFTDIRHOME=/home/cft/
CFTDIRINQ=/home/cft/fildat
CFTDIRINS=/home/cft/filinst
CFTDIRLIB=/home/cft/fillib
CFTDIRLOG=/home/cft/fillog
CFTDIRNOT=/home/cft/filnotes
CFTDIRPUB=/home/cft/filpub
CFTDIRSEC=/home/cft/filsec
CFTDIRUSR=/home/cft/filusr
CFTFICNF=/home/cft/filint/default.cfi
CFTFIDIR=/home/cft/filint
CFTHADIR=/home/cft/fildat
CFTHICNF=/home/cft/filint/default.sei
CFTHIDIR=/home/cft/filint
CFTHINI=/home/cft/fildat/sec.ini
CFTHPARM=/home/cft/fildat/secparm
CFTLOG=/home/cft/fillog/cft_log
CFTLOGA=/home/cft/fillog/cft_loga
CFTPARM=/home/cft/fildat/cft_parm
CFTPART=/home/cft/fildat/cft_part
CFTPKIDIR=/home/cft/filsec/pki
CFTPKU=/home/cft/filsec/pki/pkibase
CFTTRKCNF=/home/cft/fildat/trkapi.cfg

If you don't have them, search the "ENV_CFT" file and source it.

After, to send a file, you have to use CFTUTIL like this :

$ CFTUTIL send part=partnerid,IDF=idtrf,FNAME=/full/path/to/file/to/send

I you didn't define a CFTSEND parameter in CFT, and sending a text file, you must use "FTYPE=T" in the command.

Now, if I understand correctly your script, you have to do this :

$ cd ascii
$ for file in $(ls)
do
    CFTUTIL send part=SABDE,IDF="%%E",FNAME=$(pwd)/${file},FTYPE=T,PARM=$file
done

On the other side (partner SABDE), you will find the original name of the file in the CFT variable "&PARM" (without the path).

To see the status of your transfers, use the command:

CFTUTIL listcat part=SABDE

OK ? :slight_smile: