Open multiple terminal tabs, execute commands and continue working on them - linux

When I type:
gnome-terminal --tab -e 'ls' --tab -e 'ls'
Two new tabs opens in a new terminal window with the 'ls' results, but the prompt is not displayed and no more useless. I want to continue working in these tabs normally.
Can you help me? :)

Try this:
gnome-terminal --tab -e 'ls; exec bash'
Or
gnome-terminal --tab -e 'bash -c "ls; exec bash"'

Related

Gnome terminal doesn't recognise commands when started from startup-applications with .sh file

I am trying to use an .sh script to start a terminal when ubuntu boots. Gnome-terminal successfully starts up but when commands start executing such as (roscore, roslaunch or rosrun) it displays an error as follows: "bash: roslaunch command not found". Is there any way to fix this problem or any other way to start launch files of ROS with a visible terminal at start?
This is how my .sh file looks like
#!/bin/bash
gnome-terminal --geometry=40x40 \
--tab --title="roscore" -e "bash -c \"source ~/.bashrc;roscore;exec bash\"" \
--tab --title="navigation" -e "bash -c \"sleep 38;roslaunch navigation.launch;exec bash\"" \
--tab --title="robot" -e "bash -c \"sleep 28;roslaunch robot_config.launch;exec bash\""
Are you sourcing ros setup.bash file (source /opt/ros/$ROS_DISTRO/setup.bash)? If not just add it to ~/.bashrc file

Linux Gonme: Start multiple terminals and execute a command in each one

How can I implement the following scenario in Ubuntu Linux?
I want to go to my console, then execute ./startdev.sh and then
1) Terminal 1 pops up, starts /home/foobar/bla1.sh
2) Terminal 2 pops up, starts /home/foobar/bla2.sh
3) Terminal 3 pops up, starts /home/foobar/bla3.sh
I already figured that the command "gnome-terminal & disown" starts a new terminal.
However, until now, I don't know how to run a command in that terminal.
I accept any answer that gives me either the entire implementation for startdev.sh or a list of commands that I can use.
Thank you!
Try this content for startdev.sh:
#!/bin/bash
gnome-terminal --command=/home/foobar/bla1.sh & disown
gnome-terminal --command=/home/foobar/bla2.sh & disown
gnome-terminal --command=/home/foobar/bla3.sh & disown
But it is not clear for me why you need to disown the launched processes.
Try this script
If you need to simultaneously pop all terminals
#!/bin/bash
gnome-terminal -e "bash -c '/home/foobar/bla1.sh; sleep 10'" | gnome-terminal -e "bash -c '/home/foobar/bla2.sh; sleep 10'" | gnome-terminal -e "bash -c '/home/foobar/bla3.sh; sleep 10'"
else if you need to run commands one by one terminal then .,
#!/bin/bash
gnome-terminal -e "bash -c '/home/foobar/bla1.sh; sleep 10'"
gnome-terminal -e "bash -c '/home/foobar/bla2.sh; sleep 10'"
gnome-terminal -e "bash -c '/home/foobar/bla3.sh; sleep 10'"
this script will open multiple terminals and execute the command given within the quotes and i have used sleep to hold the terminal from exiting if not added gnome-terminal will execute command and exit immediately.

Bash script with multiple sudo commands in tabs

I have a bash script that opens a mate-terminal with 3 tabs, each tab having a command that requires sudo. The problem is that I have to put in my sudo password on each of the 3 tabs, which is not ideal. Can I make it so I only have put in my sudo password once? Basically, I want to double click the shell script, put in my sudo password once, and have all 3 commands execute. How can I do this? This script looks like this:
#!/bin/sh
mate-terminal \
--tab -e "sudo /sbin/mgetty -s 115200 -D /dev/ttyUSB0" \
--tab -e "sudo tail -f /var/log/mgetty/mg_ttyUSB0.log" \
--tab -e "sudo tail -f /var/log/messages"

Linux shell scripting for different tabs

I want a script,which after executing will open multiple tabs and a specified command will run on every tab.Basically that command is ssh i.e. for connecting to other machines.
you can try something like this;
gnome-terminal --tab --title "server1" -x bash -c "ssh -t user1#host1 'nohup yourCommand'" --tab --title "server2" -x bash -c "ssh -t user2#host2 'nohup yourCommand'"

How to execute a file in separate gnome terminal in linux

I want to execute a C program in separate terminal, I've tried this command,
gnome-terminal -x ./test
and
gnome-terminal -e test
But it opens a new terminal and before giving me output, it just vanish.
How could I solve this issue using gnome-terminal?
Thanks in advance
This might be what you search:
gnome-terminal -e "bash -c \"!!; exec bash\""
or (shortly):
gnome-terminal -x sh -c "!!; bash"
It opens gnome-terminal with your last command (!!) executed and it stays open with the command output in the shell, even with an interactive command like top or less...
In your case its:
gnome-terminal -e "bash -c \"./test; exec bash\""
or
gnome-terminal -x sh -c "./test; bash"

Resources