windows Linux 相当于 DOS 的“启动”命令?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/591667/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:05:19  来源:igfitidea点击:

Linux equivalent of the DOS "start" command?

windowslinuxscripting

提问by Alceu Costa

I'm writing a ksh script and I have to run a executable at a separate Command Prompt window.

我正在编写 ksh 脚本,并且必须在单独的命令提示符窗口中运行可执行文件。

采纳答案by vartec

I believe you mean something like xterm -e your.sh &

我相信你的意思是 xterm -e your.sh &

Don't forget the final &

别忘了决赛 &

回答by rogerdpack

xdg-openis a similar command line app in linux.

xdg-open是 linux 中类似的命令行应用程序。

see https://superuser.com/questions/38984/linux-equivalent-command-for-open-command-on-mac-windowsfor details on its use.

有关其使用的详细信息,请参阅https://superuser.com/questions/38984/linux-equivalent-command-for-open-command-on-mac-windows

回答by Joachim Kerschbaumer

maybe it′s not a seperate window that gets started, but you can run some executables in background using "&"

也许它不是一个单独的启动窗口,但您可以使用“&”在后台运行一些可执行文件

e.g.

例如

./myexecutable &

means your script will not wait until myexecutable has finished but goes on immediately. maybe this is what you are looking for. regards

意味着您的脚本不会等到 myexecutable 完成而是立即继续。也许这就是你要找的。问候

回答by user906489

xdg-open is a good equivalent for the MS windows commandline start command: xdg-open file opens that file or url with its default application xdg-open . opens the currect folder in the default file manager

xdg-open 是 MS windows 命令行启动命令的一个很好的等效项: xdg-open 文件使用其默认应用程序 xdg-open 打开该文件或 url。在默认文件管理器中打开当前文件夹

回答by lastlee

One of the most useful terminal session programs is screen.

screen 是最有用的终端会话程序之一。

screen -dmS title executable

You can list all your screen sessions by running

您可以通过运行列出所有屏幕会话

screen -ls

And you can connect to your created screen session (also allowing multiple simultaneous/synchronized sessions) by running

您可以通过运行连接到您创建的屏幕会话(也允许多个同时/同步会话)

screen -x title

This will open up the emulated terminal in the current window where executableis running. You can detach a screen session by pressing C-a C-d, and can reattach as many times as you wish.

这将在当前executable运行的窗口中打开模拟终端。您可以通过按 Ca Cd 来分离屏幕会话,并且可以根据需要多次重新连接。

回答by Troels Arvin

If you really want your program started in a new terminal window, you could do something like this: xterm yourtextmodeprogram or gnome-terminal -e yourtextmodeprogram or konsole -e mc

如果你真的希望你的程序在一个新的终端窗口中启动,你可以这样做: xterm yourtextmodeprogram 或 gnome-terminal -e yourtextmodeprogram 或 konsole -e mc

Trouble is that you cannot count on a particular terminal emulator being installed, so (again: if you reallywant to do this) you would need to look for the common ones and then execute the first one encountered.

问题是你不能指望安装一个特定的终端模拟器,所以(再次:如果你真的想这样做)你需要寻找常见的,然后执行遇到的第一个。

As Joachim mentioned: The normal way to do this is to background the command (read about shell job control somewhere, if you want to dig deeper).

正如 Joachim 提到的:执行此操作的正常方法是将命令置于后台(如果您想深入了解,请在某处阅读有关 shell 作业控制的信息)。

There are also cases where you want to start a persistent shell, i.e. a shell session which lives on when you close the terminal window. There are two ways to do this:

在某些情况下,您还想启动一个持久的 shell,即一个在您关闭终端窗口时继续存在的 shell 会话。有两种方法可以做到这一点:

  • batch-oriented: nohup command-to-run &
  • interactive: screen
  • 面向批处理:nohup 命令运行 &
  • 互动:屏幕

回答by Luke Cardeaux

Some have recommended starting it in the background with &, but beware that that will still send all console output from the application you launch to the terminal you launched it from. Additionally, if you close the initial terminal the program you loaded will end.

有些人建议使用 & 在后台启动它,但请注意,这仍会将您启动的应用程序的所有控制台输出发送到您启动它的终端。此外,如果您关闭初始终端,您加载的程序将结束。

If you're using a desktop environment like KDE or GNOME, I'd check the alt+f2 launching apps (gnome-open is the one for GNOME, I don't know the name of the KDE app) and see if you can pass them the command to launch as an argument.

如果您使用的是 KDE 或 GNOME 等桌面环境,我会检查 alt+f2 启动应用程序(GNOME 是 gnome-open,我不知道 KDE 应用程序的名称),看看您是否可以将要启动的命令作为参数传递给他们。

Also, if your intention is to launch a daemon, you should check the nohupdocumentation.

此外,如果您打算启动一个守护进程,您应该查看nohup文档。

回答by Javier

if you want a new windows, just start a new instance of your terminal application: in kde it's

如果您想要一个新窗口,只需启动终端应用程序的新实例:在 kde 中

konsole -e whatever

i'm sure the Gnome terminal has similar options

我确定 Gnome 终端有类似的选项