tcof...@gmail.com
unread,Nov 28, 2016, 7:03:48 PM11/28/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Yet another Expect for Java
using the following code.
Expect expect = new ExpectBuilder()
.withOutput(channel.getOutputStream())
.withInputs(channel.getInputStream(), channel.getExtInputStream())
.withEchoOutput(System.out)
.withEchoInput(System.err)
.withInputFilters(removeColors(), removeNonPrintable())
coupled with jsch to connect to an HP procurve switch. "removeNonPrintable()" doesn't appear to be working. I see the following output in debug.
###############################################################################
[?7l [3;23r [?6l [1;1H
[?25l [1;1HProCurve J9087A Switch 2610-24-PWR
Software revision R.11.89
Copyright (C) 1991-2011 Hewlett-Packard Co. All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.
HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303
Press any key to continue [?25h [24;27H [?7l [3;23r [?6l [24;27H [?25h [24;27H [?6l [1;24r [?7l [2J [24;27H [1;24r [24;27H [2J [?7l [1;24r [?6l [24;1H [1;24r [24;1H [24;1H [2K [24;1H [?25h [24;1H [24;1sw1>
when viewed in putty the above loks like this
ProCurve J9087A Switch 2610-24-PWR
Software revision R.11.89
Copyright (C) 1991-2011 Hewlett-Packard Co. All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.
HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303
Press any key to continue
###############################################################################
I tried to use
.withInputFilters(removeColors(), removeNonPrintable(),replaceInString("[\\p{Cntrl}]", ""))
but that doesn't seem to work either. I suspect I need different regex to strip out the ANSI garbage but am not able to come up with a working solution.
Any suggestions greatly appreciated.