Call a script from Obj-c (or Xcode/Cocoa)

Joined
Sep 10, 2008
Messages
61
Reaction score
1
Points
8
I have started learning Xcode as of the 3.0 release. My C coding experience is years old but it is coming back. I just need to tack on the Objective-c part. Time is all I need.

But, I have years worth of scripts (mostly perl) that I definitely don't want to rewrite into obj-c. I can easily call a Obj-c executable from Perl, but so far I haven't managed to call a perl script from inside of Obj-c. I suspect that I am not seeing the forest for the trees and the method is so simple that I am overlooking it.

Note: I am not trying to integrate Perl inside of Xcode as in using Camelbones or suchlike. Just a simple call to an external program and return.

Anybody got an example?
Konan
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
system( "cat /dev/null > /tmp/mymd5s" );
or
system( [myNSStringCommand UTF8String] );

Of course that won't return any values except the status, I think. You'd have to read the output from a file.

You might want to look into NSTask and NSPipe.
 
OP
K
Joined
Sep 10, 2008
Messages
61
Reaction score
1
Points
8
system( "cat /dev/null > /tmp/mymd5s" );
or
system( [myNSStringCommand UTF8String] );

Of course that won't return any values except the status, I think. You'd have to read the output from a file.

You might want to look into NSTask and NSPipe.

Hmmm. System is what I was trying. Must have gotten the syntax wrong.

Anyway, the scripts just grab data out of mysql then put it back so they don't have to return values to the caller. Yet

Thanks
Konan
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top