@@ -0,0 +1,2593 @@
+package net.sf.expectit;%0A%0A/*%0A * #%25L%0A * ExpectIt%0A * %25%25%0A * Copyright (C) 2014 Alexey Gavrilov and contributors%0A * %25%25%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *      http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * #L%25%0A */%0A%0Aimport com.jcraft.jsch.Channel;%0Aimport com.jcraft.jsch.JSch;%0Aimport com.jcraft.jsch.JSchException;%0Aimport com.jcraft.jsch.Session;%0A%0Aimport java.io.IOException;%0Aimport java.util.Properties;%0A%0Aimport static net.sf.expectit.filter.Filters.removeColors;%0Aimport static net.sf.expectit.filter.Filters.removeNonPrintable;%0Aimport static net.sf.expectit.matcher.Matchers.*;%0A%0A/**%0A * An example of interacting with the local SSH server%0A */%0Apublic class SshLocalhostExample %7B%0A    public static void main(String%5B%5D args) throws JSchException, IOException %7B%0A        JSch jSch = new JSch();%0A        Session session = jSch.getSession(System.getenv(%22USER%22), %22localhost%22);%0A        Properties config = new Properties();%0A        config.put(%22StrictHostKeyChecking%22, %22no%22);%0A        jSch.addIdentity(System.getProperty(%22user.home%22) + %22/.ssh/id_rsa%22);%0A        session.setConfig(config);%0A        session.connect();%0A        Channel channel = session.openChannel(%22shell%22);%0A%0A        Expect expect = new ExpectBuilder()%0A                .withOutput(channel.getOutputStream())%0A                .withInputs(channel.getInputStream(), channel.getExtInputStream())%0A                .withInputFilters(removeColors(), removeNonPrintable())%0A                .build();%0A        try %7B%0A            channel.connect();%0A            expect.expect(contains(%22$%22));%0A            expect.sendLine(%22pwd%22);%0A            // a regexp which captures the output of pwd%0A            System.out.println(expect.expect(regexp(%22(?m)%5C%5Cn(%5B%5E%5C%5Cn%5D*)%5C%5Cn%22)).group(1));%0A            expect.sendLine(%22ls -l%22);%0A            // skipping the echo command%0A            expect.expect(contains(%22%5Cn%22));%0A            // getting the output of ls%0A            System.out.println(expect.expect(regexp(%22.*%5C%5C$%22)).getBefore().trim());%0A            expect.sendLine(%22exit%22);%0A        %7D finally %7B%0A            channel.disconnect();%0A            session.disconnect();%0A            expect.close();%0A        %7D%0A    %7D%0A%7D%0A

Add example for localhost