Jump to content

Linux Scripting Help


Bhawan
 Share

Recommended Posts

Hi all, I have been trying to write a simple script to automate some tasks but i have hit a point where I just can't figure this out.

I want to run multiple commands simultaneously in foreground (in different console windows) so somewhat like this:

konsole command1
konsole command2
konsole commant3

but the problem is that it waits for the first command to finish before executing the second one but the commands do not end (the aren't supposed to) and so it never starts the next command because it waits for the first command to finish and it never finishes.

I have also tried this:

konsole command1 &
konsole command2 &
konsole command3

however, this doesn't work for me either because this makes em all run in background and not in foreground.

I just want it to run all those commands in foreground so can you guys please help me with this.

Thanks

Edited by Bhawan
Link to comment
Share on other sites

Create a script for each command, then in a new script, start all of them with the & at the end of the line and they should all run in the background. To see them in a console, I think you just type jobs, then it gives you a # and the script name. You can then do fg # to bring it to the front.

http://linuxreviews.org/beginner/jobs/

ex: launch.sh

#!/bin/bash

script1 &
script2 &
script3 &
script4 &

Link to comment
Share on other sites

Create a script for each command, then in a new script, start all of them with the & at the end of the line and they should all run in the background. To see them in a console, I think you just type jobs, then it gives you a # and the script name. You can then do fg # to bring it to the front.

http://linuxreviews.org/beginner/jobs/

ex: launch.sh

#!/bin/bash

script1 &
script2 &
script3 &
script4 &

Thank you very much :D I'll give it a shot when I finish my homework.

BTW: Is there a way I can filter out the job id for a specific process and then copy that to a variable so that later on i can just go " fg $VARIABLE " ?

thanks

Edited by Bhawan
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...