【问题标题】:How to execute commands in new tabs?如何在新选项卡中执行命令?
【发布时间】:2016-04-09 19:39:44
【问题描述】:

我想启动两个不同的数据库,但想让每个进程在终端的单独选项卡中运行。如何在 shell 脚本中执行此操作?我目前有以下代码:

#! /bin/bash
mysqld &
redis-server

每个数据库都需要自己的选项卡。这是在 OSX 上。

【问题讨论】:

  • 标签?您想要两个 interactive shell 窗口向数据库输入/输出一些信息吗?那么,为什么不在单独的 shell 中运行它们呢?对于监视输出,您还可以将输出重定向到 日志文件Also you can start screenscreen -S 'itismysqld' -d -m mysqld,然后,稍后附上:screen -r itismysqld

标签: macos shell scripting


【解决方案1】:
osascript -e 'tell application "Terminal" to activate' -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' -e 'tell application "Terminal" to do script "mysqld" in selected tab of the front window'

(基于https://stackoverflow.com/a/7177891/1566267

类似的命令用于redis-server

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-04
    • 2017-05-19
    相关资源
    最近更新 更多