Welcome to Centmin Mod Community
Register Now

if then run a .sh script format

Discussion in 'System Administration' started by pamamolf, Sep 21, 2017.

  1. pamamolf

    pamamolf Well-Known Member

    2,767
    245
    63
    May 31, 2014
    Ratings:
    +436
    Local Time:
    8:00 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Hello :)

    Looking for some help on how to run a script .sh :)

    Code:
    if [ $? -eq 0 ]
    then
     exit
    else
     sh /etc/folder/script.sh
    fi
    I am wondering if that is correct (or any better way) to run it like a direct way (without the sh in front):

    Code:
     /etc/folder/script.sh
    Thank you
     
    Last edited: Sep 21, 2017
  2. eva2000

    eva2000 Administrator Staff Member

    30,577
    6,854
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,275
    Local Time:
    4:00 PM
    Nginx 1.13.x
    MariaDB 5.5
    don't need .sh extensions as long as you have the sha-bang line to tell it to use bash http://tldp.org/LDP/abs/html/sha-bang.html
    for me and Centmin Mod scirpts it's
    Code (Text):
    #!/bin/bash
    

    as to sh in front not needed if the actual script has the correct sha-bang head line
     
    • Informative Informative x 1