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

    4,125
    429
    83
    May 31, 2014
    Ratings:
    +841
    Local Time:
    7:16 AM
    Nginx-1.29.x
    MariaDB 10.6.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

    58,893
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    2:16 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    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