Join the community today
Become a Member

if then run a .sh script format

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

  1. pamamolf

    pamamolf Well-Known Member

    2,978
    275
    83
    May 31, 2014
    Ratings:
    +485
    Local Time:
    7:33 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

    32,255
    7,165
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,892
    Local Time:
    3:33 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