[RUBY] Create an executable file in a scripting language

Write the line starting with #! On the first line of the file as shown below.

hoge.rb


#!/usr/bin/env ruby

(Program contents)

#! Is a shebang, a command written below it that will re-execute itself. By using / usr / bin / env, you don't have to write the environment-dependent PATH that appears in which ruby. / usr / bin / env is also environment-dependent, but it is almost common, and if you can execute env with this PATH even if it is not included by default, it will be a problem after that I think it's okay because it doesn't exist.

After that

$ chmod +x hoge.rb

If you give execute permission,

$ ./hoge.rb

Can be executed like.

In other languages, you can replace the ruby part with perl, python, etc.

hoge.py


#!/usr/bin/env python

Supplement

Used to specify the character code,

# coding: utf-8

Etc. are brought to the second line, so it's OK.

reference

http://x68000.q-e-d.net/~68user/unix/pickup?%A5%B7%A5%A7%A5%D0%A5%F3%A5%B0

Recommended Posts

Create an executable file in a scripting language
Create a binary file in Python
[GPS] Create a kml file in Python
Create an executable file (EXE) by PyInstaller in a hybrid environment (Nimporter) of Python + Nim
Create a GUI executable file created with tkinter
How to create a JSON file in Python
Create a MIDI file in Python using pretty_midi
Create a web server in Go language (net/http) (2)
I made a package to create an executable file from Hy source code
A tool that makes a standalone jar an executable file
Create a web server in Go language (net / http) (1)
Create a function in Python
Create a dictionary in Python
Create a dummy data file
Create an exe file that works in a Windows environment without Python with PyInstaller
How to use NUITKA-Utilities hinted-compilation to easily create an executable file from a Python script
A note for embedding the scripting language in a bash script
Note 2 for embedding the scripting language in a bash script
How to temporarily implement a progress bar in a scripting language
Count specific strings in a file
Create a CSV reader in Flask
Create a DI Container in Python
Create an Excel file with Python3
Start SQLite in a programming language
Create a 1MByte random number file
Create a Kubernetes Operator in Python
Save a YAML-formatted file in PyYAML
Create a random string in Python
How to create a config file
Create a file uploader with Django
Create a LINE Bot in Django
Create an instance of a predefined class from a string in Python
Scripting Language C ——How a text file without a shebang is executed
How to create a heatmap with an arbitrary domain in Python
Read the config file in Go language! Introducing a simple sample
Get the formula in an excel file as a string in Python
Create a shortcut to run a Python file in VScode on your terminal
Create a simple GUI app in Python
Quickly create an excel file with Python #python
Create a JSON object mapper in Python
[GO language] Let's read a YAML file
Create a large text file with shellscript
Test & Debug Tips: Create a file of the specified size in Python
Create a VM with a YAML file (KVM)
Create a Python-GUI app in Docker (PySimpleGUI)
Create a deb file from a python package
Script to create a Mac dictionary file
Creating a virtual environment in an Anaconda environment
Create a high-level synthesis language assembler. Part 6
Create an upgradeable msi file with cx_Freeze
Create a web service in Flask-SQLAlchemy + PostgreSQL
Create a Python image in Django without a dummy image file and test the image upload
Create an elliptical scatter plot in Python without using a multivariate normal distribution
Addressed an issue where IIS couldn't import a pyd file in a Django project
Create a filter to get an Access Token in the Graph API (Flask)
Read a file containing garbled lines in Python
Use a scripting language for a comfortable C ++ life
I want to create a window in Python
Create a standard normal distribution graph in Python
Create a PDF file with a random page size
Create a virtual environment with conda in Python