Piping Strangeness
Piping Strangeness
- Subject: Piping Strangeness
- From: mw <email@hidden>
- Date: Sat, 30 Nov 2002 10:24:16 -0500
Hello,
Here's a simple question for all of you: can I open a read AND a write pipe
to a perl program? For example, the perl program accepts input using STDIN
(like the Apple docs say it should), performs a function or two, and then
prints the result(s) back to the Cocoa program (also like described in apple
docs).
Here is the code I am using:
[perlTask setStandardOutput: perlReadPipe];
[perlTask setStandardInput: perlWritePipe];
[perlTask setLaunchPath: @"/usr/bin/perl"];
[perlTask setArguments: [NSArray arrayWithObject:perlProgPath]];
[perlTask launch];
dataToWrite = [NSData dataWithBytes:[textFieldContents cString]
length:[textFieldContents cStringLength]];
[pipeWriteHandle writeData: dataToWrite];
perlResult = [pipeFileHandle availableData];
[self setTheTextView: perlResult];
[perlTask release];
In the case of this simple practice program, some text is entered in a text
field and is piped to the Perl program, where it is then simply printed back
to the Cocoa program and displayed (by the Cocoa program) in a text view. I
was just trying to open both a read pipe and a write pipe. When I run the
cocoa program, enter some text in the text field, and then press the button
to run the perl program, it just hangs. It is hanging on the line that calls
[pipeFileHandle availableData];
I also put some debugging in the Perl program to print a text file out with
the text received from the Cocoa program (using STDIN), and the text is
correct. I don9t understand why the Cocoa program isn't retrieving the
results from the Perl program.
Any ideas?
TIA,
mw
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.