Running multiple lines of code parallel in different terminals using bash [duplicate] - linux

This question already has answers here:
How do you run multiple programs in parallel from a bash script?
(19 answers)
bash - Shell script opening multiple terminals and executing distinct commands [closed]
(1 answer)
Closed 5 years ago.
I am new to programming. I am writing a bash script which runs 2 different programs.
This is my script.
#!/bin/bash
./ngrok http 3005
node index2.js
The first command starts ngrok and the second one starts my local server. I noticed that they are executing one after the other. I want them to run parallel in 2 different terminal in linux. How do I do this?

Related

Scheduling a bash script? [duplicate]

This question already has answers here:
How can I select random files from a directory in bash?
(13 answers)
How to run a bash script every hour and how to kill it on cloud desktop?
(2 answers)
Closed 12 months ago.
I'm using a raspberry pi for a digital art project by displaying images in a ascii form on a monitor but I would like it to rotate through random images in the folder every hour. I have a bash script set up to just run the basic command down below.
ascii-image-converter Pictures/IMAGE HERE.png -c -C --color-bg -f -m " .-=+!##$%&*()"
How would I add a random function to this command and time the bash script to run at certain intervals?

Unable to print the public ip in shell script [duplicate]

This question already has answers here:
What is the difference between $(command) and `command` in shell programming?
(6 answers)
Closed 4 years ago.
Hi I am trying to print the public ip of the machine in a file using shell script. I am using the command
ip=${curl ipinfo.io/ip}
in my script file and it gives an error saying bad substitution. whereas this command works when i run it in command line.
Is this the right way to get the ip through the script?
Thanks in advance!!
You are capturing the result of program so you should use $(). The following should work for you (with the -s parameter to curl stopping unnecessary output)
ip=$(curl -s ipinfo.io/ip)

Does command in shell script wait to complete execution of previous command? [duplicate]

This question already has answers here:
Is it possible for bash commands to continue before the result of the previous command?
(6 answers)
Closed 6 years ago.
I want to make shell script to deploy .WAR on tomcat. since I need to build it everytime and building war takes bit time. I want to make whole procedure to be done using shell script. And as a newbie to linux I dont have much idea about it.
command 1 (to build war- takes some time to build).
command 2 (to depoy war to tomcat)
Does command 2 wait for execution of command 1 to get complete or it executes before whole execution.
Yes, command 2 will execute only after command 1.

keep the shell script running even after moving to some other shell using script command without logging out from any terminal [duplicate]

This question already has answers here:
How to make a program continue to run after log out from ssh? [duplicate]
(6 answers)
Closed 6 years ago.
I have a script with one of its command let say "cmd" this cmd will move the user from the shell to some other server/shell , now when I run this script after executing "cmd" the shell gets changed (normal behaviour) but the commands following the "cmd" will not run and when I logout from the new terminal to come back to original one then only that commands execute on their own .
Is there any way so that the remaining will execute on the new terminal ?
I'm assuming your "cmd" is ssh opening a session on another server. If thats the case you can instruct ssh to run a command once the session is open: ssh user#server.com your_command_here

How do i run a for loop in bash one after another [duplicate]

This question already has answers here:
bash script order of execution
(2 answers)
Closed 7 years ago.
I have about 100 files in a folder but I would like the for loop in bash to run one after the other and not all at once. This is my script on the command line:
for i in *.fasta; some program here & done
This runs the script in the background and does all 100 files at once which crashes my server because it is memory intensive. I would like it to run one after the other automatically.
thanks!
for i in *.fasta; do some program here; done
or if you want to run the whole loop in the background
for i in *.fasta; do some program here ; done &

Resources