{"id":2097,"date":"2021-06-10T16:08:07","date_gmt":"2021-06-10T13:08:07","guid":{"rendered":"https:\/\/www.scalahosting.com\/kb\/?p=2097"},"modified":"2021-06-10T16:16:00","modified_gmt":"2021-06-10T13:16:00","slug":"how-to-use-the-shebang","status":"publish","type":"post","link":"https:\/\/www.scalahosting.com\/kb\/how-to-use-the-shebang\/","title":{"rendered":"How to use the shebang"},"content":{"rendered":"<p><b>Shebang gets its name from # and ! which are known as \u201cshell\u201d and \u201cbang\u201d<\/b><span style=\"font-weight: 400;\"> respectively. It is used in Linux system scripts to indicate the path to \u201cBash\u201d (<\/span><i><span style=\"font-weight: 400;\">the standard command-line interpreter for most Linux systems<\/span><\/i><span style=\"font-weight: 400;\">).\u00a0<\/span><\/p>\n<p><b>How the shebang is used will depend on what language you are creating the script for. Here are some common shebang syntaxes:<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Script Language<\/b><\/td>\n<td><b>Syntax<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Standard bash shell<\/span><\/td>\n<td><span style=\"font-weight: 400;\">#!\/bin\/bash<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">System boot script<\/span><\/td>\n<td><span style=\"font-weight: 400;\">#!\/bin\/sh<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Perl<\/span><\/td>\n<td><span style=\"font-weight: 400;\">#!\/usr\/bin\/perl<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Python<\/span><\/td>\n<td><span style=\"font-weight: 400;\">#!\/usr\/bin\/python<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Python 2.6<\/span><\/td>\n<td><span style=\"font-weight: 400;\">#!\/usr\/bin\/python2.6<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Python 3<\/span><\/td>\n<td><span style=\"font-weight: 400;\">#!\/usr\/bin\/python3<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Ruby<\/span><\/td>\n<td><span style=\"font-weight: 400;\">#!\/usr\/bin\/ruby<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">PHP<\/span><\/td>\n<td><span style=\"font-weight: 400;\">#!\/usr\/local\/bin\/php<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">From the table above, you may note that the shebang <\/span><b>for different versions of <\/b><a href=\"https:\/\/www.scalahosting.com\/kb\/how-to-connect-to-mysql-using-python\/\"><b>Python <\/b><\/a><span style=\"font-weight: 400;\">each has individual syntax. This separation is necessary since the interpreter for each of those <\/span><b>versions is located in separate directories<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Excluding a Shebang from Your Scripts<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">If the shebang is not included in a script file it is typical that the default path will be <\/span><b>\u201c\/bin\/sh.\u201d <\/b><span style=\"font-weight: 400;\">However, even if that is the desired outcome it is generally preferable to specify the <\/span><b>\u201c\/bin\/sh\u201d <\/b><span style=\"font-weight: 400;\">with a shebang.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The exception to this rule is when<\/span><b> a script is sourced in another script.<\/b><span style=\"font-weight: 400;\"> In cases such as this, it is acceptable not to include the shebang.<\/span><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Shebang gets its name from # and ! which are known as \u201cshell\u201d and \u201cbang\u201d respectively. It is used in Linux system scripts to indicate the path to \u201cBash\u201d (the standard command-line interpreter for most Linux systems).\u00a0 How the shebang is used will depend on what language you are creating the script for. Here are [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[34],"tags":[],"class_list":["post-2097","post","type-post","status-publish","format-standard","hentry","category-web-hosting"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/2097","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/comments?post=2097"}],"version-history":[{"count":1,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/2097\/revisions"}],"predecessor-version":[{"id":2098,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/2097\/revisions\/2098"}],"wp:attachment":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/media?parent=2097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/categories?post=2097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/tags?post=2097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}