在Ubuntu的终端系列执行命令 [英] Executing commands in a series in ubuntu terminal
问题描述
假设我有一组命令在Ubuntu终端中执行:
对于如:
Suppose I have a set of commands to be executed in ubuntu terminal: for eg:
sudo apt-get update
sudo install xrdp
sudo install java
.....
和其他许多人。
是在Ubuntu可以在默认情况下执行该文件包含这些命令和无需人工干预执行(比如是/否),是吗?
Is it possible in ubuntu to execute the file containing these commands and execute without human intervention (like yes/no) , by default yes?
我尝试安装葡萄酒,执行$酒CMD / C Commands.bat,把所有这些命令.bat文件,但得到错误后,应用程序试图创建一个窗口,但没有驱动程序可以加载。
那么,有没有在Ubuntu执行一系列命令的任何简单的方法?
I tried installing wine , executing $wine cmd /c Commands.bat , after putting all these commands in .bat file but getting errors "Application tried to create a window, but no driver could be loaded." So, is there any simple way of executing a series of commands in ubuntu?
推荐答案
你在说什么 - 在一个文件中多个命令 - 被称为shellscript里
What you are talking about - multiple commands in one file - is called a "shellscript".
让我们说你有 commands.sh
:
sudo apt-get update
sudo install xrdp
sudo install java
然后,你可以使用执行的命令:
Then you could execute the commands using:
bash commands.sh
您也可以直接执行shellscript里出使用所谓的 家当<它的/ code>
机制。
将这个行 commands.sh
#!/bin/bash
..和使文件的可执行文件:
.. and make the file executable:
chmod +x commands.sh
现在你可以直接执行它:
Now you can execute it directly:
./commands.sh
如果你想要说是所有的问题,你可以使用是
命令:
yes | bash "file_with_commands.sh"
这篇关于在Ubuntu的终端系列执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!