• Rob's side project: I recently started Gun-Forums.com and we currently have a $100 raffle - if you're into guns, join up and enter the raffle to win $100.00. Raffle Link

Basic Script

let_s_begin

New Member
Im trying to write a script where it would run about 6 or 7 programs when i run it. with each program waiting a second after one has loaded before it runs, so that they will all pop up one at a time.
this is what i wrote.
terminator &&
sleep 1 &&
terminator &&
sleep 1 &&
terminator &&
sleep 1 &&
terminator &&
sleep 1 &&
firefox &&
sleep 1 &&
keepassxc &&
sleep 1 &&
gnote &&
sleep 1 &&
okular
now when it reaches firefox it stops until i exit firefox
 


JasKinasis

Well-Known Member
Try this instead:
Bash:
#!/us/bin/env bash
terminator &
sleep 1
terminator &
sleep 1
terminator &
sleep 1
terminator &
sleep 1
firefox &
sleep 1
keepassxc &
sleep 1
gnote &
sleep 1
okular &
That will start all of the applications in the background and the script will sleep for 1 second, before starting the next application in the background.
You don’t need all of the conditional, logical AND operations (&&). That will only start the next application if the previous application returns 0 (success) to the shell.

Also - AFAIK terminator is Python based, so I imagine that the script that starts a new terminator window returns 0 (success) which allows your script to move on.

Whereas Firefox is a hashed executable and will not return anything to the shell until it is closed. Which is why your script is hanging at Firefox, until Firefox is closed.
The way to get around that is to start Firefox (and all other applications) in the background using & at the end of the line.
But we don’t want to invoke sleep in the background!

I hope that makes things a little clearer?!
 

Rob

Administrator
Staff member
You may also be able to open multiple terminator windows (or terminator w/ split windows) at the beginning.. for instance, I know you can save terminator w/ the windows already split, so it opens like that next time.. you could even edit the config to make each pane run a program/script upon opening.

Edit: Rabbit hole --> https://askubuntu.com/questions/869756/spawn-new-terminator-tabs-from-bash-script
 
Last edited:


Members online


Top