Pranaam to all bhai ji _/\_
Today we will discuss about running .c .pl .py .sh files using linux shell terminal .
most of time we get confused whether we need to use compiler/interpreter for running a program file or we can just use ./ to run them.
let have a look and clears when to use ./ instead of compiler/interpreter and how to use it :)
Compiling and Running .c files :-
.c files and written in 'C' language (Mother of programming and Linux)
for executable of c program , first we need to compile the source code then make executable from that compiled code .
lets have a look :)
suppose we have a file of code having name indishell.c
so first of all we need to produce compiled code of indishell.c file and for that , we use gcc compiler (already installed in linux bydefault)
command for compiling c program using gcc compiler
gcc -o compiled_code_file_name your_c_program_file.c
here gcc is the compiler that will produce compiled code of c program file
-o stands for output
compiled_code_file_name is the suggested name for the compiled code file that gcc would create
for example i want to produce compiled code file with name indishell and my c program file is indishell.c
command will be like this
gcc -o indishell indishell.c
your_c_program_file.c is the name of your c program file name (i am using indishell.c)
once you got the compiled code , you need to make it executable by changing its permission
we can add executable permission on a file by using chmod command
command will be
chmod +x compiled_code_file_name
for example we want to make indishell compiled code as executable
command will be
chmod +x indishell
now we have to just execute by issuing command
./compiled_code_file_with_executable_permission
in my case , compiled code with executable permission is indishell
so command will be
./indishell
thats it :D
./ is use to execute program file
Running .pl (perl code) files:-
.pl files are program files coded in perl language
we dont need to compile them and we can run file directly either using perl or change its permission and add executable permission to it so that we can run it using ./
suppose we have a .pl having name indishell.pl , we have 2 method to run it
first one is , using perl
command is
perl file.pl
for example
perl indishell.pl
second method is , change permission of file and make it executable by using command chmod and we will be able to run it directly
lets start , we have indishell.pl file
we need to make it executable by adding execute permission to it
command will be
chmod +x indishell.pl
and then we can run pl file using ./file.pl
like this one
Running .py (python code) files:-
just like perl code file , we can run .py (python code file) files
.py files are program files coded in python language
we dont need to compile them and we can run file directly either using python or by adding executable permission to it so that we can run it using ./
suppose we have a .py having name indishell.py , we have 2 method to run it
first one is , using python
command is
python file.py
for example
python indishell.py
second method is , change permission of file and make it executable by using command chmod and we will be able to run it directly
lets start , we have indishell.py file
we need to make it executable by adding execute permission to it
command will be
chmod +x indishell.py
and then we can run py file using ./file.py
like this one
Running .sh (shell script) files:-
.sh files are program files coded in shell scripting
we dont need to compile them and we can run file directly either using sh or by adding executable permission to it so that we can run it using ./
suppose we have a .sh having name indishell.sh , we have 2 method to run it
first one is , using sh
command is
sh file.sh
for example
sh indishell.sh
second method is , change permission of file and make it executable by using command chmod and we will be able to run it directly
lets start , we have indishell.sh file
we need to make it executable by adding execute permission to it
command will be
chmod +x indishell.sh
and then we can run sh file using ./file.sh
like this one
well this was about running c,perl,python and shell script based program file using their compiler/interpreter and without using them
note:-
if you dont know about file compiler/interpreter , its best just to change its permissions(add executable permission to file) and then use ./ to run it
for example we have file.run file
we dont know in which programming lnguage it is developed , we can go for
chmod +x file.run
then
./file.run
this procedure will run our unknown file without knowing its compiler/interpreter :)
Thank you
Greetz to :-
<3 Zero cool , Team INDISHELL Leads, Hardeep bhai(cyber gladiator) and AR AR bhai ji <3
0 comments