Question:
How can I spawn a new konsole using a shell script in Linux?
Clapflam
2008-10-08 15:36:30 UTC
I'm using BackTrack 3 and I've written a couple of shell scripts to automate some of the boring tasks. However, some of these tasks need to run at the same time in seperate konsole windows, this means I need to write seperate scripts for each task and need to open a new konsole myself to start the script. For example at the moment I have to:-

Open konsole
Type script1.sh

Open another konsole
Type script2.sh

Open a third konsole
Type script3.sh

Basically I was wondering if there's a way to either write a script containing all the tasks where each is assigned to a different konsole or window. Or a command which can spawn konsoles setting them off running their own scripts. For example then I'd only have to:-

Open konsole
Type scriptx.sh

Hope that made sense! Cheers
Four answers:
anonymous
2008-10-08 15:46:30 UTC
There's a better way of doing this, using the "screen" command. It will open as many virtual terminals as you need. Add this command to your script:



screen -A -m -d -S



The command will run in the background, and you are even free to close the terminal you are using. To look at any individual task, open a terminal and type:



screen -r



To stop looking at one of these tasks, press CTRL+A, then "d" for detach. To stop a task, use CTRL+A, then "k" for kill.
jplatt39
2008-10-08 22:52:58 UTC
Just two thoughts:



Depending on which shell you want to run /bin/bash will start a new shell (console, xterminal or whatever).



& at the end of a command as in:



jplatt@Hugo2 ~ $ canfield& is going to start the command canfield and run it in the background.



I hope you aren't on kubuntu because I can never be sure that they have all the programs you need. Type "info coreutils" at the konsole. If it doesn't appear download info and coreutils. Sensibly, they should be installed by default.



Anyhow, that's where you should get most of the information you need.
Tizio 008
2008-10-08 23:49:23 UTC
i dont understand how useful it can be.

if you need "multitasking", append &.

if you need to catch the "stream" of each script independently, consider redirection towards file descriptor greater than 2 [meaning: new files :D]



if you really want a terminal showing the output of the execution of each script,



konsole -e sh script.sh &

konsole -e sh script2.sh &

.

.

sh could be bash

the --noclose option could be useful
Guerrilla Gorilla
2008-10-08 22:42:10 UTC
I don't know if konsole has an option to allow you to run a command in it via the command like, but it would look something like this if it did:



#!/bin/bash

konsole --execute script1.sh &

konsole --execute script2.sh &

konsole --execute script3.sh &


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...