[Date Prev] [Date Index] [Date Next] [Thread Prev] [Thread Index] [Thread Next]

Re: Problems exec consoles using expect scripts

Bryan Stansell bryan@conserver.com
Wed, 8 Jan 2014 22:57:53 GMT


Well, I was successful enough to dig up what's going on and a way of working around it, but I still don't understand the underlying issue (which is turning into: why is the Ubuntu distribution working differently than CentOS, MacOSX, and Solaris).

The issue, seen from traces, is that expect is not able to open /dev/tty on Ubuntu when running under conserver (which releases the controlling tty, etc when daemonizing).  Apparently expect does some manipulations of the tty modes when it has access to /dev/tty and for an unknown reason to me, it is being denied on Ubuntu.  Because of this, it's not setting it's own ptys into a "passthrough" mode (raw, no echo, etc).  So, you end up with two layers of processing happening and all the goofiness you see (echoed commands, control characters printed but also "working", etc).

I took a snapshot of the tty settings on CentOS and, by using them, you can do this missing work for expect within the expect script.  All I did was add

  exec stty 0:0:bf:0:3:1c:8:40:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0

to the top of the expect script and those magic entries reset things to the proper modes.  I also had basic success using "exec stty raw -echo".  Using the symbolic names is safer and what I recommend, but I'll leave it up to you to enumerate all the settings to make a complete set.  I was looking for the easy way out.  :-/

So the big question is: why is Ubuntu not playing like the other kids on the block.  Maybe /dev/tty access is enforced differently, maybe the daemonization process is resulting in different process states (more or less "cleansed"), etc.  Not sure I'm going to dig into it, but if someone tracks down the root cause, and it's something conserver is doing wrong (which would be surprising to me as I know folks have been using expect with conserver a long time - but you never know), I'm up for any pointers or patches.

Hopefully this gets you going and helps anyone else that might trip up here.  If this workaround doesn't work for you, that would be good to know too, of course.

Bryan

On Jan 8, 2014, at 8:09 AM, Bryan Stansell <bryan@conserver.com> wrote:

> Sorry, I haven't had a chance yet.  But thanks for the reminder - I'v got the VM running again and I'll start poking at it...
> 
> Bryan
> 
> On Jan 8, 2014, at 1:38 AM, Tore Anderson <tore@fud.no> wrote:
> 
>> * Bryan Stansell
>> 
>>> Good news is I was able to replicate the issue on my shiny new Ubuntu
>>> VM.  I haven't got a clue why it's happening, though I haven't dug in
>>> much.  More poking around as I have time...
>> 
>> Hi Bryan,
>> 
>> Now that the holidays are past us, I was wondering if you did find out
>> anything more about this issue?
>> 
>> Best regards,
>> Tore Anderson
> 
> 
> _______________________________________________
> users mailing list
> users@conserver.com
> https://www.conserver.com/mailman/listinfo/users