Cannot change console mode during usage of expect

2015-04-14 Thread Keith Proctor
Hello, my name is Keith Proctor.  I test FileMaker Server and I have written 
a test suite on Macintosh. The tests work beautifully on  Macintosh. I’m trying
to Use Cygwin on Windows to reduce the amount of rewriting that I must do 
on the Windows side.The test includes a dynamically created interactive call
that uses expect to spawn fmsadmin and then interact with fmsadmin by 
providing a user name or a password.  An example is below:

expect -c "spawn fmsadmin open -y -u userName
expect -r .+:
send myPassword\r
interact"

The issue is that the following phrases appear and won’t allow my interactive 
expect command to continue.

GetConsoleMode  // prints once
SetConsoleMode  // prints once
ReadConsoleInput// spews while collecting input from the command line.

Perform the actions of the script above by hand in the Cygwin CLI does NOT 
cause an issue.  The issue only happens when using expect.  I have tried 3
shells so far (mintty, bash, rxvt).  Are there more?  Mintty provides access to
the terminal types.  So far I have tried xterm-256, vt100, vt120.

An example of the code looks like:

   fdwMode = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT
  | ENABLE_PROCESSED_INPUT; 
   if (! SetConsoleMode(hStdin, fdwMode) )
// print error to console

Since FileMaker Server runs on Macintosh or Windows it is doubtful that
I can get a change made in the fmsadmin application. I’m new to CygWin
so I’m hoping that I’ve missed a setting somewhere or maybe I need to
install another module.  

Help me Obi-Wan your my only hope.  ;)

Keith

Re: Cannot change console mode during usage of expect

2015-04-15 Thread Keith Proctor
Corinna Vinschen  cygwin.com> writes:

> 
> On Apr 15 01:17, Keith Proctor wrote:
> > Hello, my name is Keith Proctor.  I test FileMaker Server and I have
> > written a test suite on Macintosh. The tests work beautifully on  
> > Macintosh. I’m trying to Use Cygwin on Windows to reduce the 
> > amount of rewriting that I must do on the Windows side.The
> > test includes a dynamically created interactive call that uses 
> > expect to spawn fmsadmin and then interact with fmsadmin by 
> > providing a user name or a password.  An example is below:
> > 
> > expect -c "spawn fmsadmin open -y -u userName
> > expect -r .+:
> > send myPassword\r
> > interact"
> > 
> > The issue is that the following phrases appear and won’t allow
> > my interactive expect command to continue.
> > 
> > GetConsoleMode  // prints once
> > SetConsoleMode  // prints once
> > ReadConsoleInput// spews while collecting input from the command line.
> 
> I don't understand this.  What does Cygwin expect have to do
>  with these underlying OS calls?!?  They only work in a console 
> window and they are not to be suppsoed to be used by Cygwin
>  executables since all the underlying OS details are (more or less)
>  hidden behind the TTY code. Also, how are they supposed to work
>  in a PTY which is constituted by  Named Pipes, not a console?  
> And expect certainly uses PTYs to perform its pseudo-interactive stuff.
> 
> Corinna
> 
Corinna,  Let me make this a little clearer fmsadmin application is making
the 3 calls.  In this case fmsadmin is being called from expect and expect
is the cause of the issue.  If I don't use expect fmsadmin works without the
spam of the ReadConsoleInput strings.  IOW the calls to the Getter and
Setter methods work correctly.  The output looks something like this 
when I do it by hand.

>fmsadmin open -y -u userName
>password:myPassword
Opening file: someFile.fmp12
Opening file: someOtherFile.fmp12
Opened file: someFile.fmp12
Opened file: someOtherFile.fmp12

So this works as expected in the Cygwin Window when doing the 
command by hand.  It is somehow an interaction between Cygwin and
the expect command not allowing the Setter/Getter methods for Console
Mode to be accepted.  I have NO understanding WHY this would be the
case.  All I did was localize down the behavior and the failure to work
correctly.

I am still hoping that the default settings are somehow wrong and 
I need to make some small change to Cygwin to allow 
GetConsoleMode and SetConsoleMode calls to correctly
work.

On a very related note I see this same question being asked for years
and the Cygwin answer has been change your code to work with
Cygwin.  Unfortunately, I don't have that luxury.  fmsadmin is a
DOS application.  I may never be able to get a fix for this issue in
fmsadmin as our target is NOT Cygwin.  

BTW, I expect GetConsoleMode and SetConsoleMode is standard
usage by any console application.  These calls work on Macintosh,
Windows and Cygwin window without expect.

HTH and many thanks,
Keith

Re: Cannot change console mode during usage of expect

2015-04-15 Thread Keith Proctor
Mark Geisert  maxrnd.com> writes:

> 
> Keith Proctor writes:
> > BTW, I expect GetConsoleMode and SetConsoleMode is standard
> > usage by any console application.  These calls work on Macintosh,
> > Windows and Cygwin window without expect.
> 
> Are you sure you're using the Cygwin expect, and not a Windows-native expect
> that just happens to be on your path?
> 
> ..mark
> 
> 
Typing which expect comes back with /usr/bin/expect.  This appears 
to be the standard Cygwin location. 

I did a search for expect on the system before installing Cygwin and
did not find an executable.  This is a fresh 2k8 R2 VM.  I did not install
another expect command from another source on the system and 
DOS does not include an expect functionality that I am aware of.  Web
shows that I would need to install another package such as HPs
expect or ActiveState.




--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Cannot change console mode during usage of expect

2015-04-15 Thread Keith Proctor
Mark Geisert  maxrnd.com> writes:


Interesting your system does the quoting.  I just left it in place.

Your last shows some hope for this issue.  It would be great if the 
solution can be a configuration change so I don't have to pre-pend
something.  Again trying to make the original code duel platform.

In response to your question:  Unfortunately, the code prints
those strings directly to console and provides no additional
information.  If this happens, in DOS, I'm assuming that we
would just want to fix anything that spews those 3 strings.
The Console Mode should simply be settable.

Keith


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Cannot change console mode during usage of expect

2015-04-15 Thread Keith Proctor
Interesting...I found the expect executable on disk, double clicked it
and it opened a window so I typed in my original expect program
without expect -c and surrounding quotes.  I then ran it and found
the same errors.  The GetConsoleMode() and SetConsoleMode()
calls are not being allowed to exit the expect environment.  

I'm not sure that the shim will work or not but I'll give it a shot.


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Cannot change console mode during usage of expect

2015-04-15 Thread Keith Proctor
Marco Atzeri  gmail.com> writes:


Thanks Marco but I'm not sure which direction your asking me
to go.  Should I:

1) Install Console2 ( I didn't find it in the Cygwin installer)
2) Build the tool mentioned in the link and prepend
build/console.exe to all my DOS commands.  

The second seams like a bit of a hack and I would have to do
the equivalent of #define for Windows versus Mac in my code.

Maybe I missed missed another option?

Inquiring minds Inquire, :)
Keith


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Cannot change console mode during usage of expect

2015-04-16 Thread Keith Proctor
Marco Atzeri  gmail.com> writes:


OK, I've done both this morning and neither work.  I've figured out
a bit more, In general, expect is working with non password tests.  
So I have turned off anything that would test a password and I'm
 running my automation now.

Again to be clear... fmsadmin works in the Cygwin window when 
typing in commands by hand.  It is the interaction with expect that
is the issue.  Now we know it's specifically password handling.

Keith

P.S.

Last comment is just in passing and for my understanding.  Why 
install Cygwin on Windows if you can't interact with the local 
Windows executables.  If your not suppose to run any of the local
Windows applications then why not just install Linux or some other
flavor of unix.  I believe the ONLY interesting part of Cygwin is 
allowing the interaction between Windows and Unix and the effort
fails if integration is not allowed and extended. It's one thing to be
a purest but I believe the over 2000 people who downloaded winpty
would agree with me.  BTW it's OK that you disagree.  This is just my
opinion and I'm trying to use Cygwin to save a lot of effort and help
your effort along the way.  So far, except for this one thing it has
helped me.  :)


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple