views:

277

answers:

3

I need a create a specific type of file in OS X. It needs resources in a specific way. Currently, the only way I can find to do this is in AppleScript with an OSAX. This is slow, about 1 second round trip to run, since the OSAX must open, load, do it's job, and quit. I have explored doing it in C, but that would be a last resort, as there always seems to be issues building apps out to make them work across multiple machines.

I was thinking, perhaps perl, or ideally bash could pull it off, but I am not 100% sure. The specs of what I need to do are as follows:

  • Create a text file, formatted as an email message (RFC 822/RFC 2822 format).

  • Text files must have an 'STR ' resource ID 8192 with an email address (will be used as the SMTP MAIL FROM address) and an 'STR#' resource ID 8192 with the recipient addresses (will be used as the SMTP RCPT TO addresses).

  • The text file should have CRLF as the line endings, and a 'BODY' resource ID 8192 should be added.

  • The 'BODY' resource should contain a 4 byte value, '822 ' for an unspecified body type, '7BIT' for 7-bit data, '8BIT' for 8-bit data, and 'BINM' for binary data.

Of course, the text file creation parts are simple, but stuffing those 'STR ' resources in has me stumped.

+1  A: 

I think this previous question is what you want to do.

plinth
Thanks. Not really what I am after though. That answer suggests to use Rez, or similar. Assuming those would work, which I am not entirely sure, they would at the very least, require me to distribute them with my app. I can not do that, as it is Apple's software in Dev Tools.
+1  A: 

Have you had a look at REALbasic? That makes it much easier than C to program something like this. You won't get that for free, though.

Otherwise, explain more what languages you can use. You're talking of an app you're distributing - is that app's job only to create this file out of the blue?

Also, I do not understand your issue with C and "building apps out to make them work across multiple machines."

Thomas Tempelmann
The question has the applescript tag, so I believe he wants to write a script that creates the resources, then distribute the script.
Peter Hosey
A: 

Hi, yes, Real Basic can do this. In a nutshell, I use an oddball email server, and in order for it to take an email from the command line, I have to build a text file in a certain way, then move it to a certain folder, and the email will be delivered. The developer seems to like the resource forks, and that probably will not change.

I can currently do this with an OSAX in applescript, at the expense of only 1 message per second being created. Real Basic is going to be about the same.

As for C, I wrote a small command line app once, my first app, all it did was read the first few bytes of a file, convert some endianess values around, and return a integer. I had issues distributing it, since it would need to be built out on each platform. That is my only experience with C.

Yes, this apps job would only be to create this file. I know php really well, perl enough to get by at least reading it and editing it. Basically, I have fiddled in scripting languages for the better part of 10 years.

I imagine using this script like this: ./sendemail -f [email protected] < path/to/rfc822/email.txt

Thanks for any pointers.