本文整理汇总了Java中com.pty4j.PtyProcess.exec方法的典型用法代码示例。如果您正苦于以下问题:Java PtyProcess.exec方法的具体用法?Java PtyProcess.exec怎么用?Java PtyProcess.exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.pty4j.PtyProcess
的用法示例。
在下文中一共展示了PtyProcess.exec方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import com.pty4j.PtyProcess; //导入方法依赖的package包/类
public void connect() throws IOException {
if (localTerminalPanel == null) {
throw new IllegalStateException("local terminal panel is not set");
}
if (pty != null && pty.isAlive()) {
return;
}
String[] cmd = {"/bin/bash", "-i"};
Map<String, String> envs = new HashMap<>(System.getenv());
envs.remove("TERM_PROGRAM"); // for OS X
envs.put("TERM", "vt102");
pty = PtyProcess.exec(cmd, envs, System.getProperty("user.home"));
OutputStream os = pty.getOutputStream();
InputStream is = pty.getInputStream();
PrintStream printStream = new PrintStream(os, true);
localTerminalPanel.setPrintStream(printStream);
Runnable run = new TerminalWatcher(is, localTerminalPanel.getTextArea());
thread = new Thread(run);
thread.start();
}
示例2: createTtyConnector
import com.pty4j.PtyProcess; //导入方法依赖的package包/类
@Override
public TtyConnector createTtyConnector() {
try {
Map<String, String> envs = Maps.newHashMap(System.getenv());
String[] command;
if (UIUtil.isWindows) {
command = new String[]{"cmd.exe"};
} else {
command = new String[]{"/bin/bash", "--login"};
envs.put("TERM", "xterm");
}
PtyProcess process = PtyProcess.exec(command, envs, null);
return new LoggingPtyProcessTtyConnector(process, Charset.forName("UTF-8"));
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
示例3: initializeProcess
import com.pty4j.PtyProcess; //导入方法依赖的package包/类
private void initializeProcess() throws Exception {
String userHome = System.getProperty("user.home");
Path dataDir = Paths.get(userHome).resolve(".terminalfx");
IOHelper.copyLibPty(dataDir);
if (Platform.isWindows()) {
this.termCommand = "cmd.exe".split("\\s+");
} else {
this.termCommand = "/bin/bash -i".split("\\s+");
}
if(Objects.nonNull(shellStarter)){
this.termCommand = shellStarter.split("\\s+");
}
Map<String, String> envs = new HashMap<>(System.getenv());
envs.put("TERM", "xterm");
System.setProperty("PTY_LIB_FOLDER", dataDir.resolve("libpty").toString());
this.process = PtyProcess.exec(termCommand, envs, userHome);
process.setWinSize(new WinSize(columns, rows));
this.inputReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
this.errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
this.outputWriter = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
ThreadHelper.start(() -> {
printReader(inputReader);
});
ThreadHelper.start(() -> {
printReader(errorReader);
});
process.waitFor();
}
示例4: TerminalEmulator
import com.pty4j.PtyProcess; //导入方法依赖的package包/类
public TerminalEmulator(String termId, SocketIOSessionOutbound outbound, String[]command, Map<String, String> envs, String workingDirectory) throws IOException {
PtyProcess pty = PtyProcess.exec(command, envs, workingDirectory);// working dir
this.termId = termId;
this.outbound = outbound;
this.ttyConnector = new ProcessTtyConnector(pty, charset);
}
示例5: startProcessWithPty
import com.pty4j.PtyProcess; //导入方法依赖的package包/类
@NotNull
public Process startProcessWithPty(@NotNull List<String> commands, boolean console) throws IOException {
Map<String, String> env = new HashMap<String, String>();
setupEnvironment(env);
if (isRedirectErrorStream()) {
LOG.error("Launching process with PTY and redirected error stream is unsupported yet");
}
File workDirectory = getWorkDirectory();
boolean cygwin = myUseCygwinLaunch && SystemInfo.isWindows;
return PtyProcess.exec(ArrayUtil.toStringArray(commands), env, workDirectory != null ? workDirectory.getPath() : null, console, cygwin,
ApplicationManager.getApplication().isEAP() ? getPtyLogFile() : null);
}
示例6: createProcess
import com.pty4j.PtyProcess; //导入方法依赖的package包/类
@Override
protected PtyProcess createProcess(@Nullable String directory) throws ExecutionException {
Map<String, String> envs = new HashMap<String, String>(System.getenv());
envs.put("TERM", "xterm-256color");
EncodingEnvironmentUtil.setLocaleEnvironmentIfMac(envs, myDefaultCharset);
try {
return PtyProcess.exec(getCommand(), envs, directory != null ? directory : currentProjectFolder());
}
catch (IOException e) {
throw new ExecutionException(e);
}
}
示例7: createProcess
import com.pty4j.PtyProcess; //导入方法依赖的package包/类
@Override
protected PtyProcess createProcess() throws ExecutionException {
Map<String, String> envs = new HashMap<String, String>(System.getenv());
envs.put("TERM", "xterm");
try {
return PtyProcess.exec(myCommand, envs, null);
}
catch (IOException e) {
throw new ExecutionException(e);
}
}
示例8: createProcess
import com.pty4j.PtyProcess; //导入方法依赖的package包/类
@Override
protected PtyProcess createProcess(@Nullable String directory) throws ExecutionException
{
Map<String, String> envs = new HashMap<String, String>(System.getenv());
envs.put("TERM", "xterm-256color");
//EncodingEnvironmentUtil.setLocaleEnvironmentIfMac(envs, myDefaultCharset);
try
{
return PtyProcess.exec(getCommand(), envs, directory != null ? directory : currentProjectFolder());
}
catch(IOException e)
{
throw new ExecutionException(e);
}
}
示例9: startProcessWithPty
import com.pty4j.PtyProcess; //导入方法依赖的package包/类
@Nonnull
public Process startProcessWithPty(@Nonnull List<String> commands, boolean console) throws IOException {
Map<String, String> env = new HashMap<>();
setupEnvironment(env);
if (isRedirectErrorStream()) {
LOG.error("Launching process with PTY and redirected error stream is unsupported yet");
}
String[] command = ArrayUtil.toStringArray(commands);
File workDirectory = getWorkDirectory();
String directory = workDirectory != null ? workDirectory.getPath() : null;
boolean cygwin = myUseCygwinLaunch && SystemInfo.isWindows;
return PtyProcess.exec(command, env, directory, console, cygwin, getPtyLogFile());
}