Re: One for the Unix gurus
Re: One for the Unix gurus
- Subject: Re: One for the Unix gurus
- From: ryan <email@hidden>
- Date: Fri, 25 Jun 2004 20:36:06 -0700
One of the problems here is that most unix apps which output only
flush the buffers at the end of a line. There are ways around some of
these things, and lots of apps detect the difference between running
under a tty (ie: in terminal) versus running from a pipe (as you are
doing). The suggestion to investigate pseudo-ttys is a bit overboard,
many programs do what you are suggesting without resorting to ptys.
Ptys are very complex to program - I've tried it... even 'advanced
programming in the unix environment' couldn't help me. Even reading
telnet source code wasn't helpful either. Best to avoid.
Unfortunately I am big on talk but little on documentation/pointers.
Google will probably be your best friend here. If you are still stuck
you can email me later and I should have more time to dig up a thing
or two,
Regards,
-ryan
On Fri, 25 Jun 2004 20:21:53 -0600, John Pannell
<email@hidden> wrote:
>
>
Hi Glenn-
>
>
While I'm not a Unix guru, I have worked with interactive tasks a bit.
>
I believe the issue you are encountering is that most CLI apps believe
>
they are working from a tty, and NSTask doesn't perfectly replicate
>
this. Any responses that are buffered on the CLI side do not get
>
flushed to the NSPipe you are listening/talking to.
>
>
Some example code I have used in the past seems to have disappeared
>
from the web; I did a quick search and came across this, which should
>
be informative (in fact, his project seems to be much like your own...)
>
>
http://projects.tynsoe.org/en/stm/index.php
>
>
You can search the mamasam archive for "pseudo-tty" for previous
>
discussions on the subject.
>
>
Hope this helps!
>
>
John
>
>
>
>
On Jun 25, 2004, at 6:32 PM, Glenn Zelniker wrote:
>
>
> I need to integrate some ssh functions (primarily scp) into an
>
> application and I've been experimenting with writing wrappers around
>
> Unix commands. I'm taking the usual approach -- using NSTask, NSPipe,
>
> and NSFileHandle. I launch the task from the proper location, pass the
>
> command-line arguments via an NSArray, pipe stdin, stdout, and stderr
>
> as needed, and react to NSNotifications triggered by asynchronous
>
> background reads. This works fine for simple commands like "ls" and
>
> I've verified that I can execute "ls" with multiple command-line
>
> arguments, such as "ls -l -a /myfiles." I've also verified that I get
>
> output through the pipe I set up for stdout and errors through the
>
> pipe for stderr. So far, so good...
>
>
>
> The problem is that I can't seem to get things like scp or ftp
>
> working. For example, when running ftp from the command line, one
>
> normally sees on the terminal a stream of information welcoming you to
>
> the host, disclaimers, and finally an FTP> prompt. When I run ftp from
>
> the GUI I've written (and I'm sure the arguments are being parsed
>
> correctly), I only see the FTP> prompt in the NSTextView I've set up
>
> to log stderr. Where does the other "stuff" go? It doesn't seem to go
>
> to the pipe I've set up for stdout. When I set the associated handle
>
> for readInBackgroundAndNotify, I'm looking out for
>
> NSFileHandleReadCompletionNotification. Should I be using a different
>
> notification and is this why I'm missing the welcome notice? Is there
>
> a place besides stdout and stderr that it's going to?
>
>
>
> I won't even talk about the stuff I'm trying to send to the command's
>
> input -- I want to understand what's happening with the output first!
>
> Any help would be appreciated immensely.
>
>
>
> Glenn Zelniker
>
> _______________________________________________
>
> 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.
>
_______________________________________________
>
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.
_______________________________________________
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.