FROM : emoy
DATE : Thu Nov 21 22:50:01 2002
On Thursday, November 21, 2002, at 10:18 PM, Nick Kocharhook wrote:
> I have a perl script that I'm calling from an NSTask. The script
> requires some modules that aren't standard, so I have included them in
> the project. When I launch the NSTask, though, I get an @INC error
> complaining that it can't find the modules.
>
> Any ideas? TIA
>
> ====
> NSTask *task = [[NSTask alloc] init];
> NSPipe *pipe = [NSPipe pipe];
>
> NSString *thisBundlePath = [[NSBundle bundleForClass:[self class]]
> bundlePath];
> NSString *getLinks = [NSString
> stringWithFormat:@"%@/Contents/Resources/getLinks.pl",
> thisBundlePath];
> NSString *perl = [NSString
> stringWithFormat:@"-I\"%@/Contents/Resources/Perl\"",
> thisBundlePath];
>
> [task setStandardInput:pipe];
> [task setLaunchPath:@"/usr/bin/perl"];
> [task setArguments:[NSArray arrayWithObjects:perl, getLinks]];
> [task launch];
> ====
>
> And now for the perl error:
>
> Can't locate HTML/TreeBuilder.pm in @INC (@INC contains:
> "/Users/nick/Development/TD/build/TD.app/Contents/Resources/Perl"
> /sw/lib/perl5/darwin /sw/lib/perl5 /sw/lib/perl5/darwin /sw/lib/perl5
> /System/Library/Perl/darwin /System/Library/Perl /Library/Perl/darwin
> /Library/Perl /Library/Perl /Network/Library/Perl/darwin
> /Network/Library/Perl /Network/Library/Perl .) at
> /Users/nick/Development/TD/build/TD.app/Contents/Resources/getLinks.pl
> line 3.
You don't want the extra double quotes:
NSString *perl = [NSString
stringWithFormat:@"-I%@/Contents/Resources/Perl",
thisBundlePath];
You might need the double quotes if you are passing arguments to the
shell to run, but with NSTask, the arguments are passed directly to
Perl, which can't find the path with double quotes in it.
------------------------------------------------------------------------
--
Edward Moy
Apple Computer, Inc.
<email_removed>
(This message is from me as a reader of this list, and not a statement
from Apple.)
DATE : Thu Nov 21 22:50:01 2002
On Thursday, November 21, 2002, at 10:18 PM, Nick Kocharhook wrote:
> I have a perl script that I'm calling from an NSTask. The script
> requires some modules that aren't standard, so I have included them in
> the project. When I launch the NSTask, though, I get an @INC error
> complaining that it can't find the modules.
>
> Any ideas? TIA
>
> ====
> NSTask *task = [[NSTask alloc] init];
> NSPipe *pipe = [NSPipe pipe];
>
> NSString *thisBundlePath = [[NSBundle bundleForClass:[self class]]
> bundlePath];
> NSString *getLinks = [NSString
> stringWithFormat:@"%@/Contents/Resources/getLinks.pl",
> thisBundlePath];
> NSString *perl = [NSString
> stringWithFormat:@"-I\"%@/Contents/Resources/Perl\"",
> thisBundlePath];
>
> [task setStandardInput:pipe];
> [task setLaunchPath:@"/usr/bin/perl"];
> [task setArguments:[NSArray arrayWithObjects:perl, getLinks]];
> [task launch];
> ====
>
> And now for the perl error:
>
> Can't locate HTML/TreeBuilder.pm in @INC (@INC contains:
> "/Users/nick/Development/TD/build/TD.app/Contents/Resources/Perl"
> /sw/lib/perl5/darwin /sw/lib/perl5 /sw/lib/perl5/darwin /sw/lib/perl5
> /System/Library/Perl/darwin /System/Library/Perl /Library/Perl/darwin
> /Library/Perl /Library/Perl /Network/Library/Perl/darwin
> /Network/Library/Perl /Network/Library/Perl .) at
> /Users/nick/Development/TD/build/TD.app/Contents/Resources/getLinks.pl
> line 3.
You don't want the extra double quotes:
NSString *perl = [NSString
stringWithFormat:@"-I%@/Contents/Resources/Perl",
thisBundlePath];
You might need the double quotes if you are passing arguments to the
shell to run, but with NSTask, the arguments are passed directly to
Perl, which can't find the path with double quotes in it.
------------------------------------------------------------------------
--
Edward Moy
Apple Computer, Inc.
<email_removed>
(This message is from me as a reader of this list, and not a statement
from Apple.)
| Related mails | Author | Date |
|---|---|---|
| Nick Kocharhook | Nov 21, 22:18 | |
| emoy | Nov 21, 22:50 | |
| Nick Kocharhook | Nov 22, 00:15 |






Cocoa mail archive

