Questions tagged [expectj]

It is a Java implementation of the Unix expect utility.

ExpectJ can be used for automating interaction with either a process (through stdin / stdout) or a telnet session. It is a Java implementation of the Unix expect utility.

As easy like:

// Create a new ExpectJ object with a timeout of 5s
ExpectJ expectinator = new ExpectJ(5);

// Fork the process
Spawn shell = expectinator.spawn("/bin/sh");

// Talk to it
shell.send("echo Chunder\n");
shell.expect("Chunder");
shell.send("exit\n");
shell.expectClose();

// Done!
18 questions
9
votes
2 answers

how to implement expect "interact" command using java

I want to implement the expect "interact" command using java. In expect, it's possible to open an ssh session, authenticate and, then, use the "interact" command to give the control back to the user. Is that possible with java? I've tried with…
user1073494
3
votes
0 answers

How to wrap rsync with interactive login using Java?

I am trying to wrap rsync using java, and I have been having difficulty dealing with interactive login. I can get the unix command line utility expect to work, but I cannot seem to figure out the java equivalent ExpectJ. Here is my current…
nbren12
  • 634
  • 1
  • 7
  • 11
2
votes
1 answer

JSCH Java applet

I have embedded a JSCH SSH Java applet in a web page and need to know if it's possible to run a script (of any language like PHP) to automate logging in and running commands. I have heard of expect4j and java robot but cannot see any way to…
Rodney Wilson
  • 369
  • 1
  • 4
  • 17
2
votes
2 answers

I get a contextTypes error when I try to test a very simple component

I am new to reactjs and trying to write a unit test for a simple function. I am using enzyme and here is my test: import React from 'react'; import { shallow } from 'enzyme'; import {P} from "../../src/app/components/T"; import ToDoItem from…
Hamed Minaee
  • 2,480
  • 4
  • 35
  • 63
2
votes
2 answers

Java library to run multiple unrelated commands on a remote server via ssh

My Java application has to work like this: User select bash commands in GUI and press "send." Application return distinct and independent answers for each command (e.g. we could store them in different files). Commands each run interactively, not…
1
vote
2 answers

How to run Unix shell script in a java code using ExpectJ tool?

This is my hello.sh shell script VALID_NAME="abcd" echo "Name: " read name if [ "$name" == $VALID_NAME ]; then echo "correct" else echo "unexpected input" fi ======================================================== This is my Java…
hari
  • 1,297
  • 5
  • 17
  • 36
1
vote
1 answer

ExpectJ exception on expectinator.spawn

I'm trying ExpectJ as bigginner. And I got following code from internet. This is throwing exception at first level. Code and exception as follows. I'm using it on Mac computer. package Linux; import expectj.ExpectJ; import expectj.Spawn; import…
sugunan
  • 4,408
  • 6
  • 41
  • 66
1
vote
0 answers

How to send control chars using ExpectJ in interactive mode?

I've been using expectJ to automate some administrative tasks over ssh (jsch) for some time. It has been working well. Now I am facing an interface that accepts commands triggered by control characters. Such as CTRL+B for example. For…
Leo
  • 6,480
  • 4
  • 37
  • 52
1
vote
1 answer

How to use ExpectJ in Jython?

In our company we use Jython for some reason. I need to extend it with the ExpectJ, but I could not figure out how to do it. I managed to download the expectj-2.0.7.jar, expectj-2.0.7-sources.jar and expectj-2.0.7-javadoc.jar files and made them…
Milo
  • 655
  • 1
  • 12
  • 25
0
votes
2 answers

Error while running ssh command in java

I'm trying to run ssh command in Eclipse this way ExpectJ exp = new ExpectJ(); Spawn s = exp.spawn("ssh root@192.168.1.2"); . . . . . . . . . But i get this as the error- Pseudo-terminal will not be allocated because stdin is not a…
hari
  • 1,297
  • 5
  • 17
  • 36
0
votes
1 answer

Java expectj execute linux command through jump box

I need to automate some linux console task. Those box are accessible via ssh password based authentication. I have my local machine (A). One linux jump box (B). And one linux production box (C). The box "C" only accessible from jump box. The jump…
sugunan
  • 4,408
  • 6
  • 41
  • 66
0
votes
1 answer

How would I use ExpectJ to call pg_dump (on PostgreSQL 8.4) in Java?

I've seen this problem many places, that is to say the problem with programmatically making backups from PostgreSQL. My solution is to use ExpectJ, but I'm having trouble getting my code to work. I have the following code: public class BackupUtility…
0
votes
1 answer

read output text on calling spawn.send()

I am new to ExpectJ Java programming. I downloaded jar's and able to do few send() and expect() methods. send() would fire a command on console and expect() would identify any prompt's so inputs can be provided. Expect only reads is there are…
Chakradhar K
  • 501
  • 13
  • 40
0
votes
1 answer

ExpectJ: How to leave from "interact" mode?

How do I leave after calling Spawn.interact()? TIA Leo
user1073494
0
votes
1 answer

expectJ - Reading InputStream from spawn.send()

With the following code I'd like to read the InputStream from spawn.send("ls | grep *.dat\n");. My calss implements Spawnable and it's method getStdout(), but have no clue how to use it. ExpectJ docs says: getStdout() - Get a stream from which the…
XorOrNor
  • 8,868
  • 12
  • 48
  • 81
1
2