-1

I have a script which runs another script.

myscript.sh

#!/bin/bash

....
cd /folder/
sh run.sh
sh another_script
...

the procedure:

So , I start running myscript.sh , the script runs it's commands.

Then, it gets to run.sh script ,which eventually ( the run.sh ) starts to serve on port 8080.At this time , I just want to stop it ( the run.sh ).And continue with the rest of the myscript.sh.

closed as unclear what you're asking by Rui F Ribeiro, sam, cas, G-Man, Kusalananda Jul 10 '16 at 7:30

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Would not it be simpler saying you want to serve the output of another_script at port 8080? Is it what you want? – Rui F Ribeiro Jul 9 '16 at 19:07
  • @RuiFRibeiro:As I said , I am runnning a script which contains various commands.When it hits the sh run.sh , the run.sh script will start to server ( after a few seconds or minute ) at 8080.Then, I just want to cancel it ,stop it.And then , continue with the rest of the script. – George Jul 9 '16 at 19:30
  • Please read you question (out load), and where it does not make sense, amend it, so that it does. – ctrl-alt-delor Jul 9 '16 at 20:32
  • @richard:I updated .I hope it is more clear.. – George Jul 9 '16 at 20:43
  • @richard:Can you let me know at which point you have problem? – George Jul 9 '16 at 20:57
0

It depends on what sh run.sh is for. Two likely possibilities, either:

  1. run.sh starts a server that needs to keep running, (and let's say this server needs a little time to get going), try:

    sh run.sh &  sleep 15s
    

Or:

  1. run.sh does a few things with I/O, tweaks a file or two, starts a server to do some work, and needs a little time to do the work, but just doesn't know when to quit, try:

    timeout 15s sh run.sh
    
  • @arc:Can't I , after the run.sh finishes it's work , hence start to server at 8080, cancel it?Like pressing ctrl+c ?And continue with the rest of the script?(of course the timeout in 2 option you have does it's work!Thanks – George Jul 10 '16 at 13:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.