I try to create an install script in bash. Lets assume i want to install samba.
I call from the mainscript the install script for samba \folder\samba.sh.
The script samba.sh should get executed in a new terminal window, so i can watch for install errors.
The script should work like follow description:
The script /mainscript.sh provides only user information, interaction, and executes multiple subscripts (/folder/subscripts.sh).
The script /mainscript.sh needs to create a new terminal window, passes the path, and the name of subscript.sh and executes them in the new terminal window.
The script /mainscript.sh must only execute one subscript (/folder/subscript.sh) at the time! If a subscript.sh is running then the mainscript must wait until the new terminal window gets closed.
The subscript.sh executes some code with root privileges.
Questions:
How can I create a new terminal window, pass the subscript, and execute it in the new terminal window?
How can I make sure that the script (mainscript.sh) only runs one subscript (subscript.sh) at the time?
This example should only clarify what i wanna do, it doesnt work !:
Mainscript.sh
#!/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)))"
x-terminal-emulator /opt/subscript1.sh
echo "samba - Installed"
x-terminal-emulator /opt/subscript2.sh
echo "samba - removed"
subscript1.sh
#!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.sh
#!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
xterm waits for the command to be finished before it returns control to the caller / shell / main script, so your second request should be fulfilled by default.
Yes i tested the -e option aber it doesnt work too.
Is this code line not a comment ? Is this code line required that the scripts run ?
#!/bin/sh
I didn't wrote this line in the subscript. Now it executes the subscript correctly.
"echo test" and the "subscript" gets executet at the same time
"echo test" should not get executet because of "read" the terminal window of the subscript stays open:
It is hard to explain a problem when i don't get an error. The created terminal window got open and got closed instant. I only saw a flash of the new terminal window. but i get this solved now with adding #!/bin/bash
Please read my last post again. The problem now is that the "echo" command gets executed at the same time the subscript gets executed, but it needs to wait until the terminal window of the subscript gets closed. How can i get this done ?
Making fools out of people in here doesn't really help. You mentioned problems with xterm explicitly in post #1 before editing it away. lxterminal showed up in post #10 only. Waste of time, yours and ours.