Also known as 'why can't my version of Rhapsody manipulate files'.
We had a situation where we needed Rhapsody to move a file from one location to another location. There does not appear to be any file system manipulation components available in Rhapsody so we settled on this guy:
So the Execute Process Filter (what is it filtering? heck if I know) seems to have been designed to run programs or scripts. Which is cool. You could write custom apps and then trigger them from Rhapsody. But I'm far too lazy to write my own exe if I don't have to. I'd rather just pass cmd.exe the appropriate arguments and make it do the work for me.
There are a couple of questions that need to be answered to make this filter more useful:
- How do you access the command line and get it to run a given command?
- What if the command is dynamic? e.g. you're building the command in a javascript filter and then want to run it in the command prompt.
Getting a cmd.exe to run a command
This is easy(ish), the executable you want to call is just cmd.exe. So you can enter the full path to it, along the lines of c:\windows\system32\cmd.exe
But, we want to pass a specific command to cmd.exe so that cmd.exe will run it. Do this using the /C argument that cmd.exe accepts:
c:\windows\system32\cmd.exe /C [your command here]
Cmd.exe will treat the string that you pass in as a command and run it in the same manner it would if you had typed it in a command line window.
Building a dynamic command and then using that in the Execute Process Filter
In a Javascript filter that runs before the Execute Process Filter you need to build your command and then save it so the Execute Process Filter can use it later:
We build up our command in the moveCommand variable, and then we save it into the moveCommand property against the message.
Then in the Execute Process Filter properties we use that moveCommand property by surrounding it with $ signs.
No comments:
Post a Comment