Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Change OBFilename
- This topic has 14 replies, 8 voices, and was last updated 16 years, 8 months ago by Jose Carrasquillo.
-
CreatorTopic
-
June 23, 2005 at 1:43 am #47851Nora KatzParticipant
Question: 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
-
CreatorTopic
-
AuthorReplies
-
-
June 24, 2005 at 1:17 pm #56898David CaragayParticipant
Nora, 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.
-
June 24, 2005 at 3:16 pm #56899AnonymousParticipant
Nora, 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,
-
June 24, 2005 at 6:58 pm #56900Nora KatzParticipant
Greg, 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
-
June 28, 2005 at 3:09 pm #56901AnonymousParticipant
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.
-
June 28, 2005 at 5:44 pm #56902Nora KatzParticipant
Greg, Are there any examples around that I can look at?
Nora
-
June 28, 2005 at 6:15 pm #56903AnonymousParticipant
I haven’t had a project where I did what I was suggesting, that’s just how I would do it. Someone will have to jump in with examples of writing procedures for directory parse. I’m writing my self a not to include a dir parse procedure in class though 😉 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.
-
June 28, 2005 at 6:32 pm #56904Bakha NurzhanovParticipant
Nora – e-mail me if you have questions.
Nora Katz wrote:Question:
Is there some way to make a filename for an OutBound File by incorporating the name of the original file?
-
December 7, 2006 at 1:24 pm #56905Jason MeltonParticipant
Hi, 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
-
December 7, 2006 at 1:58 pm #56906Jim KosloskeyParticipant
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.
-
December 7, 2006 at 3:09 pm #56907Michael HertelParticipant
I didn’t realize that I was reading a rebirth of an old post until now but…. 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
-
December 7, 2006 at 6:12 pm #56908Bakha NurzhanovParticipant
I have not had chance to install 5.4 yet and it would be great if metadata will have ability to carry FILENAME with the message through the engine. 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.
-
December 8, 2006 at 8:20 am #56909Jason MeltonParticipant
Hi Bahka, If you could post that it would be very useful.
Kind Regards,
Jason
-
December 11, 2006 at 6:09 pm #56910Bakha NurzhanovParticipant
Here is the TCL code (see attached). Please note that you need to have both TCL procs work in tandem with each other to capture file name into a global variable first and then populate USERDATA meta data field with the value of that global in the second proc. See attached screenshots for proc placement. Hopefully this helps.
-
January 29, 2008 at 3:35 pm #56911Jose CarrasquilloParticipant
Hi Bakha, Could you attach tcl proc “ftp_set_obfile_ibdel”?
Thanks,
-
-
AuthorReplies
- The forum ‘Cloverleaf’ is closed to new topics and replies.