QNX 4 expect eof problems

Hi Folks,

I’m trying to use “expect” from the /usr/free dejagnu archive, and have run
into a little bit of a problem with the eof handling. I’m wondering if anyone
has fixed it?

Basically, I’m trying to spawn something like “sin” and parse the lines coming
back into an array:

#! /usr/local/bin/expect –

Capture the global names from the sin command

proc sin_gnames {gnames} {
upvar $gnames g

set i 0
spawn sin fo in

set timeout 1
expect {
eof {
wait
return 1
} -re “([^\r]*)[\r\n]+” {
set g([expr $i]) $expect_out(buffer)
incr i
exp_continue
} timeout {
wait
return 99
}
}
}

What happens is it returns “99” indicating timeout, rather than “1”
to indicate EOF. I’ve tried a few things like spawning a shell to
then spawn the “sin fo in”, or writing the output to a file and then
using “cat filename” on it – same results.

Any suggestions for the fix to expect? My “last resort” will be to
use a shell and interact with it with a unique prompt to detect EOF,
but that’s rather ugly :slight_smile:

Thanks in advance!
-RK

[posted to comp.os.qnx as well]

Robert Krten, PARSE Software Devices; email my initials at parse dot com
Consulting, Systems Architecture / Design, Drivers, Training, QNX 4 & Neutrino
Check out our new QNX 4 and Neutrino (QRTP) books at http://www.parse.com/
Wanted PDP-8/9/10/11/12 Systems/documentation/spare parts! Will trade books!

Richard R. Kramer (rrkramer@kramer-smilko.com) wrote:
: I you move the eof case below the -re it may work better.

Nope. Same thing, get a timeout. I had a buddy verify the script on a
solaris box and it works as is, so it’s got to be a QNX port bug…

Cheers,
-RK

Robert Krten, PARSE Software Devices; email my initials at parse dot com
Consulting, Systems Architecture / Design, Drivers, Training, QNX 4 & Neutrino
Check out our new QNX 4 and Neutrino (QRTP) books at http://www.parse.com/
Wanted PDP-8/9/10/11/12 Systems/documentation/spare parts! Will trade books!

I you move the eof case below the -re it may work better.

Richard

Robert Krten wrote:

Hi Folks,

I’m trying to use “expect” from the /usr/free dejagnu archive, and have run
into a little bit of a problem with the eof handling. I’m wondering if anyone
has fixed it?

Basically, I’m trying to spawn something like “sin” and parse the lines coming
back into an array:

#! /usr/local/bin/expect –

Capture the global names from the sin command

proc sin_gnames {gnames} {
upvar $gnames g

set i 0
spawn sin fo in

set timeout 1
expect {
eof {
wait
return 1
} -re “([^\r]*)[\r\n]+” {
set g([expr $i]) $expect_out(buffer)
incr i
exp_continue
} timeout {
wait
return 99
}
}
}

What happens is it returns “99” indicating timeout, rather than “1”
to indicate EOF. I’ve tried a few things like spawning a shell to
then spawn the “sin fo in”, or writing the output to a file and then
using “cat filename” on it – same results.

Any suggestions for the fix to expect? My “last resort” will be to
use a shell and interact with it with a unique prompt to detect EOF,
but that’s rather ugly > :slight_smile:

Thanks in advance!
-RK

[posted to comp.os.qnx as well]

Robert Krten, PARSE Software Devices; email my initials at parse dot com
Consulting, Systems Architecture / Design, Drivers, Training, QNX 4 & Neutrino
Check out our new QNX 4 and Neutrino (QRTP) books at > http://www.parse.com/
Wanted PDP-8/9/10/11/12 Systems/documentation/spare parts! Will trade books!

Richard R. Kramer (rrkramer@kramer-smilko.com) wrote:
: I have expect ver 5.22.0 and tcl 7.6 here. A paraphrase of your fcn
: didn’t work until I swapped the two cases (???).

Huh :slight_smile:

I’m running 5.19.0 and 7.5 – where did you score the 5.22.0 and 7.6 (just
off the “net” or is there a pre-ported-to-qnx4-version somewhere?) I
grabbed mine off the dejagnu distribution in /usr/free…

Thanks Richard!
-RK

: Robert Krten wrote:
: >
: > Richard R. Kramer (rrkramer@kramer-smilko.com) wrote:
: > : I you move the eof case below the -re it may work better.
: >
: > Nope. Same thing, get a timeout. I had a buddy verify the script on a
: > solaris box and it works as is, so it’s got to be a QNX port bug…
: >
: > Cheers,
: > -RK
: > –
: >
: > Robert Krten, PARSE Software Devices; email my initials at parse dot com
: > Consulting, Systems Architecture / Design, Drivers, Training, QNX 4 & Neutrino
: > Check out our new QNX 4 and Neutrino (QRTP) books at http://www.parse.com/
: > Wanted PDP-8/9/10/11/12 Systems/documentation/spare parts! Will trade books!

Robert Krten, PARSE Software Devices; email my initials at parse dot com
Consulting, Systems Architecture / Design, Drivers, Training, QNX 4 & Neutrino
Check out our new QNX 4 and Neutrino (QRTP) books at http://www.parse.com/
Wanted PDP-8/9/10/11/12 Systems/documentation/spare parts! Will trade books!

I have expect ver 5.22.0 and tcl 7.6 here. A paraphrase of your fcn
didn’t work until I swapped the two cases (???).


Robert Krten wrote:

Richard R. Kramer (> rrkramer@kramer-smilko.com> ) wrote:
: I you move the eof case below the -re it may work better.

Nope. Same thing, get a timeout. I had a buddy verify the script on a
solaris box and it works as is, so it’s got to be a QNX port bug…

Cheers,
-RK

Robert Krten, PARSE Software Devices; email my initials at parse dot com
Consulting, Systems Architecture / Design, Drivers, Training, QNX 4 & Neutrino
Check out our new QNX 4 and Neutrino (QRTP) books at > http://www.parse.com/
Wanted PDP-8/9/10/11/12 Systems/documentation/spare parts! Will trade books!

It seems to me I got it off the net. I compiled it with no
appreciable hassle, as I recall, using Watcom 10.6.
I have put the executable & tcl lib at 207.114.15.68 - anonymous
/download/expect.qnxbin.5.22.tgz

Richard

Robert Krten wrote:

Richard R. Kramer (> rrkramer@kramer-smilko.com> ) wrote:
: I have expect ver 5.22.0 and tcl 7.6 here. A paraphrase of your fcn
: didn’t work until I swapped the two cases (???).

Huh > :slight_smile:

I’m running 5.19.0 and 7.5 – where did you score the 5.22.0 and 7.6 (just
off the “net” or is there a pre-ported-to-qnx4-version somewhere?) I
grabbed mine off the dejagnu distribution in /usr/free…

Thanks Richard!
-RK

: Robert Krten wrote:
:
: > Richard R. Kramer (> rrkramer@kramer-smilko.com> ) wrote:
: > : I you move the eof case below the -re it may work better.
:
: > Nope. Same thing, get a timeout. I had a buddy verify the script on a
: > solaris box and it works as is, so it’s got to be a QNX port bug…
:
: > Cheers,
: > -RK
: > –
:
: > Robert Krten, PARSE Software Devices; email my initials at parse dot com
: > Consulting, Systems Architecture / Design, Drivers, Training, QNX 4 & Neutrino
: > Check out our new QNX 4 and Neutrino (QRTP) books at > http://www.parse.com/
: > Wanted PDP-8/9/10/11/12 Systems/documentation/spare parts! Will trade books!

Robert Krten, PARSE Software Devices; email my initials at parse dot com
Consulting, Systems Architecture / Design, Drivers, Training, QNX 4 & Neutrino
Check out our new QNX 4 and Neutrino (QRTP) books at > http://www.parse.com/
Wanted PDP-8/9/10/11/12 Systems/documentation/spare parts! Will trade books!

Richard R. Kramer (rrkramer@kramer-smilko.com) wrote:
: It seems to me I got it off the net. I compiled it with no
: appreciable hassle, as I recall, using Watcom 10.6.
: I have put the executable & tcl lib at 207.114.15.68 - anonymous
: /download/expect.qnxbin.5.22.tgz

Thank you very much! I’ve grabbed it and will take a look shortly!

Cheers,
-RK

: Richard

: Robert Krten wrote:
: >
: > Richard R. Kramer (rrkramer@kramer-smilko.com) wrote:
: > : I have expect ver 5.22.0 and tcl 7.6 here. A paraphrase of your fcn
: > : didn’t work until I swapped the two cases (???).
: >
: > Huh :slight_smile:
: >
: > I’m running 5.19.0 and 7.5 – where did you score the 5.22.0 and 7.6 (just
: > off the “net” or is there a pre-ported-to-qnx4-version somewhere?) I
: > grabbed mine off the dejagnu distribution in /usr/free…
: >
: > Thanks Richard!
: > -RK
: >
: > : Robert Krten wrote:
: > : >
: > : > Richard R. Kramer (rrkramer@kramer-smilko.com) wrote:
: > : > : I you move the eof case below the -re it may work better.
: > : >
: > : > Nope. Same thing, get a timeout. I had a buddy verify the script on a
: > : > solaris box and it works as is, so it’s got to be a QNX port bug…
: > : >
: > : > Cheers,
: > : > -RK

Robert Krten, PARSE Software Devices; email my initials at parse dot com
Consulting, Systems Architecture / Design, Drivers, Training, QNX 4 & Neutrino
Check out our new QNX 4 and Neutrino (QRTP) books at http://www.parse.com/
Wanted PDP-8/9/10/11/12 Systems/documentation/spare parts! Will trade books!