Answer the question
In order to leave comments, you need to log in
How to make Wait wait for completion?
test1.sh:
#!/bin/bash
echo test
sleep 5
echo test1
sleep 2
#!/bin/bash
password=`zenity --password`
echo ${password} | sudo -S gnome-terminal -e "./test1.sh"
for word in word1 word2 word3 word4
do
echo $word
sleep 1
done
Answer the question
In order to leave comments, you need to log in
there is a simple
shell1.sh option
echo $$ >> /tmp/wait.pls
echo Process started
sleep 3
echo Process stopped
rm /temp/wait.pls
password=`zenity --password`
echo ${password} | sudo -S gnome-terminal -e "./shell1.sh"
while true
do
if [ ! -f /tmp/wait.pls ] ; then
echo "Done"
exit 0
fi
done
Found an easier solution: xterm instead of gnome-terminal.
As it turned out, he does not jump to the next command.
Example:
#!/bin/bash
# Функция для запуска команды в xterm с определёнными настройками
# 1-й параметр либо команда либо ключ -s для запуска под root
# 2-й параметр либо пустой либо команда
x(){
font_family=monospace
font_size=10
geometry=80x30
font_color=lightgrey
if ; then
if ; then
echo ${password} | sudo -S xterm -fa ${font_family} -fs ${font_size} -geometry ${geometry} -fg ${font_color} -e "$2;sleep 2"
else
echo "Нужен пароль!"
fi
else
xterm -fa ${font_family} -fs ${font_size} -geometry ${geometry} -fg ${font_color} -e "$1;sleep 2"
fi
}
# Функция проверки zenity диалогов с возможностью выхода
maybe_exit() {
if ; then
echo "Выход"
exit $?
fi
}
#sample
password=`zenity --password`
maybe_exit
x "./test1.sh"
x -s "apt update"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question