“Debian 9 64x - LXDE”
我尝试在bash中创建一个安装脚本。让我们假设我想安装samba。我从mainscript调用samba \folder\samba.sh
的安装脚本。脚本samba.sh应该在新的终端窗口中执行,所以我可以监视安装错误。
该脚本应该像以下描述一样工作:
/mainscript.sh
仅提供用户信息,交互,并执行多个下标(/folder/subscripts.sh
)。/mainscript.sh
需要创建一个新的终端窗口,传递路径和subscript.sh
的名称,并在新的终端窗口中执行它们。/mainscript.sh
当时只能执行一个下标(/folder/subscript.sh
)!如果subscript.sh
正在运行,那么主语必须等到新的终端窗口关闭。subscript.sh
使用root权限执行一些代码。问题:
mainscript.sh
)当时只运行一个下标(subscript.sh
)?例:
main script.是
#!/bin/sh
# This is the content of the mainscript.sh
# subscript1 and subscript2 must not be executed at the same time!
# the mainscript needs to wait when a subscript gets executed!
echo "hello, this script runs in terminal window (((A)))"
xterm /opt/subscript1.sh
echo "samba - Installed"
xterm /opt/subscript2.sh
echo "samba - removed"
subscript1.是
#!bin/sh
# This is the content of the subscript1
echo "This script runs in a new terminal window (((B)))"
apt-get install samba
# instructions done .... close the terminal window (((B))) now
subscript2.是
#!bin/sh
# This is the content of the subscript2
echo "This script runs in a new terminal window (((C)))"
apt-get remove samba
# instructions done .... close the terminal window (((C))) now
在澄清您确实希望在LXDE中出现新的终端窗口之后,这是一个可能的解决方案。
Debian LXDE很可能安装了xterm或lxterminal。以下示例使用lxterminal。对于xterm使用“xterm -e command”
首先在自己的窗口中执行manscript.sh:
$ lxterminal --command=/mainscript.sh
#!/usr/bin/sh
<section that provides user information>
# Call subscripts that will run in sequence
lxterminal --command=/folder/subscripts.sh
当subscripts.sh完成时,新的终端窗口将关闭并将控制权返回给mainscript.sh通过按顺序调用它们,您一次只能运行一个下标。