Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTask and readInBackgroundAndNotify



Hi all,

I'm having problems with NSTask and readInBackgroundAndNotify. In my app, I would like to execute a shell script which has been typed in a text view.
I use an NSTask calling /bin/sh, use parameter -s, passes the script as a input and read the output with readInBackgroundAndNotify. This works.

However /bin/sh doesn't read all the environment variables, so I would like to use /bin/csh or /bin/tsch instead. And here problems occurs. Most of the time I get only some part of the output, for instance for the script:
pwd ; echo "hello" ; ls
I get the pwd and echo, not the ls. (I reiterate that it works with /bin/sh; it tooks me a long time to check that all the output has to be flushed some way before termination).

Even worse: I sometimes get the output in reverse order! (in my example, the echo and THEN the pwd).

I don't understand this different behavior of csh to sh. Any clue would be gretly appreciated.

Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.