Programs

team bbl


Programs are files containing instructions that the computer executes. However, computers require instructions in machine language, not in a language that humans use. The solution is interpreters and compilersprograms that translate a human-readable file into machine language that the computer can execute.

Programming languages are the languages that humans use to write programs. Programming languages differ. Each has a very detailed syntax that allows a compiler to recognize its instructions and convert them to machine language. Some popular languages for writing programs are C, C++, Java, and Perl.

The program file that contains the instructions written in a programming language is called the source code. The source code is converted by a compiler or interpreter specific to the language. Interpreters convert the program and execute it immediately. Compilers can save the program in machine language so that the program doesn't have to be converted again every time it runs. The saved program is a binary file (a file the computer understands), called the executable. Some compilers understand more than one language.

Programs in executable files are run by typing the program name. The name includes the path. For instance, a program you write and compile in your own directory runs when you type:

 ./programname 

Programmers will find an open source C and C++ compiler developed by GNU available on most Linux systems. A simple command that compiles a C program is:

 gcc -o myprogram myprogram.c 

The -o option provides a name for the executable file. The source code is in the file myprogram.c. After gcc compiles it, you can type ./myprogram to run the program. The compiler has many options. Type man gcc to see more information about using the gcc compiler.

Most Linux systems also include Perl and Python, two open source languages. Many system administrators use Perl to write programs to manage their Linux systems. Shell scripts are also frequently used by system administrators. Shell scripts, discussed in Chapter 19, are programs containing Linux commands.

Programs can't execute unless their permissions include x for the account types that are to execute them. Even the owner can't execute a program without x permissions.

    team bbl



    Spring Into Linux
    Spring Into Linux
    ISBN: 0131853546
    EAN: 2147483647
    Year: 2005
    Pages: 362
    Authors: Janet Valade

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net