0

I am new to bash shell scripting and I need guidance to write a bash script which will execute other multiple bash scripts or php scripts. If you can help me on this I will be very thankful.

5
  • What have you tried so far? Jan 15 '20 at 13:12
  • @EduardoTrápani very basic stuff, like, echo, simple 'if else', simple 'function' etc
    – sahil 02
    Jan 15 '20 at 13:15
  • Having one script execute another is simply a matter of using the file name of the other script as a command - as long as its execution bit is set, and the file can be found. What is your problem with that?
    – Jos
    Jan 15 '20 at 13:19
  • Calling a external script is like calling echo. Just make sure the called scripts are either in the current path or you call them by full name _/path/to/script.sh. Jan 15 '20 at 13:19
  • I apologize to you, for troubling you guys with so simple stuff. But now I understood how it works. Thank you for your kind responses.
    – sahil 02
    Jan 15 '20 at 13:38
0

Most basic example vi test.sh with content:

#!/bin/bash
./test2.sh

vi test2.sh with content:

#!/bin/bash
echo "hi there" 

test.sh when executed will execute test2.sh (and expects it in the same path as test.sh).

3
  • got it. thank you so much for your help. ❤👍
    – sahil 02
    Jan 15 '20 at 13:59
  • Why use sh here? IMHO it would be better to ensure that test2.sh is executable and let its shebang take care of what interpreter to use Jan 15 '20 at 15:07
  • very basic I said :=)
    – Rinzwind
    Jan 15 '20 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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