From: <RGi...@a1...> - 2002-01-11 09:48:36
|
> I know exactly which line of Perl I'm on. It's the expect() call > that is waiting for the command output to get all transferred. But it might be interesting where the time is spent within expect()... > Yes, this is the approach I decided to take and it works fine. I > postedthe question in order to understand what Expect was doing > under the covers, > why it was so slow, and whether or not there was anything I could > tweak to > speed things up. Yes, I can code around it, but this provides me a > learning opportunity to better understand Expect. Also to find better > learning material. Sorry about the learning material. The nice thing about Perl is, if everything else fails: "Read the source, Luke!" ;-) [but don't take the Expect code as a guideline how to program in perl, it's really a mess and I'm planning a complete rewrite] Coming back to your problem: Expect should only be used for applications where you have to send different input in response to variable output, i.e. for interactive applications. If you can do the job in a shell script, then Expect is overkill. You don't use a screwdriver to hammer in your nails either, right? :-) In most cases, setting up ssh with RSA keys allows to transparently do the things you want. If you use Expect for password entry, think again. It's not secure to store passwords in the clear and there are very few cases where this is appropriate. Why Expect is slow: it's never been intended for speed applications, its sole purpose is to obviate the need for user interaction. Internally it does a select(), reads in chunks from its various data sources into accumulators (possibly truncating them) and does the pattern matching on them. > I agree, and that's what I am doing, but I'd still like to know if > there'sanything I can do to speed up Expect's data collection. It > sounds like no, there isn't. Not without a substantial rewrite. There are plans by Don Libes to do a complete rewrite of the original expect so that it can be used with various scripting languages, and that version certainly would have a better performance, but still: use the right tool for the job. Feel free to ask if you want further details about Expects innards. Hope this helps, Roland -- RGi...@cp... |