I have a problem whereby I need to extract part of a filename picked up by a file event and use it to form a new variable for use in a subsequent job.
The way I'm thinking of doing this is taking the name of the file from <Filemon.Filename> feeding that into a script which will strip off the original extension and using what's left as the root of a new filename.
So lets say the file watcher picks up a file called 12345.req. I want to send that file to a remote site where it will be processed and they will create a response file called 12345.out which I then need to ftp back to my systems. The initial string is variable and cannot be predicted. There are also several hundred possible variants (eg aaa123.req, 123xxx456.req, XXX12345.req and so on) which are machine generated by a process designed 10 years ago.
The first step is easy.ie file event calls action which calls ftp put to send the original request file. In that step I set some group variable eg GROUP_FILENAME. I want to populate a value in another group variable called say REQUEST_FILENAME
What I need to do in unix terms is something like
FILE_PREFIX= `echo $GROUP_FILENAME | sed 's/\.req//' `
I can see the logic, a lot depends on the construction of the job, group, event and action. The "varset -i" is going to look for a group's run number. The value you set for this GROUP variable with a varset will persist only for that run of the group. So assuming the file watch event triggers a job (eg my_var_set_job) to run varset, the triggered job needs to find the run number. As this triggered job will not itself be part of a group you would need to have started the group and have the group run an event (from its Job Events tab) which is triggered when the group becomes active. This would run an action which sets a public variable to the current group run number. Then, when your my_var_set_job is triggered it would do a
FILE_PREFIX= `echo $GROUP_FILENAME | sed 's/\.req//' ` ;
I send the file pause for 30 seconds to allow the remote site to generate the response.
I then have a repeating FTP GET job which runs until it gets at which point it calls an action to cancel itself so I don't poll endlessly once I've got the file. This allows the remote site whatever time they need to create the file (anything from seconds to hours) but means I don't wait around unnecessarily or annoy the remote end by having a continuous poll going on throughout the day.