It runs the process in non-interactive way

306 views
Skip to first unread message

Chris Murphy

unread,
Sep 21, 2017, 11:09:35 AM9/21/17
to Yet another Expect for Java
Hi there,

First of all, thank you for such amazing library.

In short: I used it however it run the process in "non-interactive way" so im unable to use it in the intended way.

In detail: I'm trying to automate a library which works by asking different questions and then do the process. If i run it in simple commandline and manually enter everything it simply works. However when i used it with your library then it somehoe know that its running in non-interactive mode and thus doest work.

Please advise

Alexey Gavrilov

unread,
Sep 21, 2017, 5:26:06 PM9/21/17
to Chris Murphy, Yet another Expect for Java
Hi,

Can you show some code examples? I’m curious how do you attach to the process running your library.

Regards,
-Alexey


--
You received this message because you are subscribed to the Google Groups "Yet another Expect for Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-expecti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris Murphy

unread,
Sep 22, 2017, 2:50:08 AM9/22/17
to Yet another Expect for Java
Hi Alexey,

Here is my code, im trying to automate Fastlane Library

Process process = Runtime.getRuntime().exec("/bin/bash");

Expect expect = new ExpectBuilder()
.withInputs(process.getInputStream())
.withOutput(process.getOutputStream())
.withTimeout(10, TimeUnit.SECONDS)
//.withExceptionOnFailure()
.withEchoOutput(outoutInfo)
.build();


expect.sendLine("cd /Volumes/BOOTCAMP/MyBuild");

expect.sendLine("ls");


Result result = expect.expect(contains("iPhone"));




expect.sendLine("fastlane init");


result = expect.expect(contains("Your Apple ID (e.g. fast...@krausefx.com)"));

System.out.println(result.toString());


expect.sendLine("em...@email.com");


result = expect.expect(contains("Your Apple ID (e.g. fast...@krausefx.com)"));

Alexey Gavrilov

unread,
Sep 22, 2017, 4:00:52 AM9/22/17
to Chris Murphy, Yet another Expect for Java
It looks like you are not waiting for the command to execute.

Add expect.expect(contains(PROMPT)) after each send line statement. Have a look at these examples:

Chris Murphy

unread,
Sep 22, 2017, 5:05:24 AM9/22/17
to Yet another Expect for Java
I'm actually waiting.

Alexey Gavrilov

unread,
Sep 22, 2017, 5:40:30 AM9/22/17
to Chris Murphy, Yet another Expect for Java
OK, at least you are not waiting after ‘cd’, so doubt that ‘ls’ is working as expected.

Chris Murphy

unread,
Sep 22, 2017, 7:28:33 AM9/22/17
to Yet another Expect for Java
Please check this post, as you can see the fastlane cli itself knows that whether its running in interactive (manual) or non-interactive (your library).
What do you advise?

Alexey Gavrilov

unread,
Sep 24, 2017, 2:52:43 AM9/24/17
to Chris Murphy, Yet another Expect for Java
Hi, 

You should be able to start a process from your Java program in the same way as if you run it in the terminal.
Make sure you have the same set of the environment variables in the bash shell session.

Also consider starting fastline as Java process avoid running bash shell.

Hope it helps,
Alexey

Chris Murphy

unread,
Sep 24, 2017, 10:40:26 AM9/24/17
to Yet another Expect for Java
Hi Alexy,

Also consider starting fastline as Java process avoid running bash shell.

Can you please explain with a code example how do i do it?

My current code is this
Process process = Runtime.getRuntime().exec("/bin/bash");

Expect expect = new ExpectBuilder()
.withInputs(process.getInputStream())
.withOutput(process.getOutputStream())
.withTimeout(10, TimeUnit.SECONDS)
//.withExceptionOnFailure()
.withEchoOutput(outoutInfo)
.build();


Thanks

Alexey Gavrilov

unread,
Sep 24, 2017, 11:06:58 AM9/24/17
to Chris Murphy, Yet another Expect for Java
Can you please explain with a code example how do i do it?
Replace /bin/bash with the full path to the tool you wish to interact with.

Chris Murphy

unread,
Sep 24, 2017, 12:08:42 PM9/24/17
to Yet another Expect for Java
Hi Alexy,

I just did that and it opens the macOS Terminal, however Terminal app does nothing.

Process process = Runtime.getRuntime().exec(

// "/bin/bash"
"/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal"

);


I see following in IntelliJ output 
SimpleResult{succeeded=false, before='null', group='null', input='', canStopMatching=false}
SimpleResult{succeeded=false, before='null', group='null', input='', canStopMatching=false}

Please advise.

Alexey Gavrilov

unread,
Sep 24, 2017, 3:36:01 PM9/24/17
to Chris Murphy, Yet another Expect for Java
I mean the fastlane process, not terminal.

Chris Murphy

unread,
Sep 25, 2017, 3:24:28 AM9/25/17
to Yet another Expect for Java
Sorry for noobish complaint, but i dont know how to directly run it.
Fastlane is a Ruby Gem i guess, which even downloads using Terminal and run using terminal.
Can you please guide how can i directly run it?

atul dubile

unread,
Nov 15, 2022, 4:40:51 AM11/15/22
to Yet another Expect for Java
Hi all,

I need some help.
I want to automate an interactive application and it needs 'up' and 'Down arrows'.
I want to select from the menu by using the up and down arrows.
can someone please suggest how to send the up and down arrow buttons in expect.sendLine() or expect.send() ?

Thanks

atul dubile

unread,
Dec 5, 2022, 2:40:13 AM12/5/22
to Yet another Expect for Java
Hi Team,

I need to validate the console text with the expected string.
eg. if I run the menu.py it will show the menu.
I want to store that menu in a string and validate it in my menu string.
how we can do it?
can any one please help?

Reply all
Reply to author
Forward
0 new messages