I am new to linux shell scripting. I want to write a shell script which will open terminal with multiple tabs; it should run rtsp client app in each tab.
For this, I have gone through question here in this forum and tried to code like bellow,
tab="--tab-with-profile=Default -e "
cmd="java RunRTSPClient"
for i in 1 2 3 4 5
do
#
foo="$foo $tab $cmd"
done
gnome-terminal $foo
exit 0
This is running and opens the terminal window with tabs but suddenly it will close.
I am not getting any errors.
Best Answer
Use this variant of the script to do what you want:
Generally, a script like this:
will open a new terminal with n tabs executing the
<command-line_or_script>
in each tab. This can be very useful when you want for example to open a terminal with some tabs with the interpreter at a specific path (usingcd /path
in the above script).Also, read
man bash
, this post and this post to understand the changes.I have tested these scripts and they work.