› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Change OBFilename
Is there some way to make a filename for an OutBound File by incorporating the name of the original file?
Example: inbound file name: “somefilename”
OBFILE as defined in Protocol: obfilename
unique outbound filename: obfilename_somefilename
I would use the msg metadata to pass the inbound file name to the outbound thread and then name your ob filename using this passed data.
The key will be capturing the original file name in the first place. Are you using fileset local to read the file? FTP? Did you write a file reader procedure of your own?
Once you have the file name then you will want to stash the file name in the driver control metadata field so that it travels along with the message until the end and the driver will then use that file name to write it out.
FYI, you can’t save the file name in a global variable because each thread has it’s own namespace and Cloverleaf doesn’t publish the namespace names anywhere.
Let me know how you’re reading the file and either me or someone else can tell you how to capture the file name.
Cheers,
I developed a tcl proc to process a file, so I chose the protocol: file, and I manually changed the file name each time I had a file to process. I didn’t think this procedure would be used extensively. Now, I find that I need to process quite a few files, and manually changing the file name each time was too tedious. I would like to use the protocol: fileset-local and process all files in a given folder.
Nora
Using fileset local you will have to write a directory parse TPS procedure that will save the file name in a global variable so that when the driver reads the file you can take the global variable and store it into metadata (IB data TPS). This also means that your directory parse procedure will have to restrict reads to one file at a time.
There has been a change request that has been around for a while for the engine to store the file name in metadata automatically but it hasn’t been implemented yet.
The alternative to all this would be to write a procedure that reads a file.
Are there any examples around that I can look at?
Nora
To give you a place to start, create a fileset local thread and write a simple dir parse procedure that echo’s the message text. You’ll find that it’s actually the list of files that would be read by the file driver. You can manipulate that list using TCL. What ever list of files that you continue will be the list that the driver will read.
Question:
Is there some way to make a filename for an OutBound File by incorporating the name of the original file?
Im a bit new to all of this can some and am hoping i can get some pointers from anyone that has used these bits of tcl as to where I am going wrong.
I have tried to use the above files and get an error in my output from ftp_file_archive saying can’t read “fileName” : no such variable.
I have 2 threads. conn1 using protocol fileset-ftp and collects the file with ftp_file_fetch on the directory parse tps.
Adding a few echos to the script and i can see the filename and the contents.
I then have a static raw route to conn2 which connects to another ftp server and hopefully writes the file. It seems to be this point which is dieing.
No doubt im doing something stupid 🙄
Regards,
Jason
Make sure your metadata USER field has a keyed list with the key OBFILENAME. It is from that key (OBFILENAME) that the proc in question is setting the value of fileName variable.
If the OBFILENAME does not exist in the USERDATA metadata field, then the variable fileName will not get established thus the error you see.
Jim Kosloskey
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
The 5.4 docs say that there is a new DRIVERCTL item named FILENAME to attach the inbound filename to the message.
This is cool, I’ll have to look at this closer.
-mh
Jim is absolutely right. I have another set of procs that do set OBFILENAME key list value in message metadata. Let me know if you want me to send that to you via e-mail or whether I should post it on the board.
Essentially it takes file name from inbound Fileset-Local or Fileset-FTP and stuffs it into userdata in metadata.
Drop me a message here or e-mail me.
If you could post that it would be very useful.
Kind Regards,
Jason
Hopefully this helps.
Could you attach tcl proc “ftp_set_obfile_ibdel”?
Thanks,