当前位置: 首页>>代码示例>>Java>>正文


Java PtyProcess.exec方法代码示例

本文整理汇总了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();
}
 
开发者ID:malafeev,项目名称:JFTClient,代码行数:26,代码来源:LocalTerminal.java

示例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);
  }
}
 
开发者ID:JetBrains,项目名称:jediterm,代码行数:21,代码来源:PtyMain.java

示例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();

    }
 
开发者ID:javaterminal,项目名称:cloudterm,代码行数:40,代码来源:TerminalService.java

示例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);
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:8,代码来源:TerminalEmulator.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PtyCommandLine.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:LocalTerminalDirectRunner.java

示例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);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:LocalTerminalDirectRunner.java

示例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);
	}
}
 
开发者ID:consulo,项目名称:consulo-terminal,代码行数:16,代码来源:LocalTerminalDirectRunner.java

示例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());
}
 
开发者ID:consulo,项目名称:consulo,代码行数:16,代码来源:PtyCommandLine.java


注:本文中的com.pty4j.PtyProcess.exec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。