Antara muka baris perintah: Perbezaan antara semakan

Kandungan dihapus Kandungan ditambah
Aviator (bincang | sumb.)
Aviator (bincang | sumb.)
dont ask
Baris 1:
Antara muka baris perintah (bahasa Inggeris: command line interface, singkatan CLI) merupakan satu cara berinteraksi dengan sesuatu [[sistem pengendalian]]. CLI ini boleh jadi terminal bentuk teks atau terminal berbentuk ''emulator'' bahkan mungkin juga dalam bentuk cengkerang kawalan jauh seperti [[PuTTY]].
{{Unreferenced|date=August 2006}}
{{Cleanup|date=February 2007}}
{{Mergefrom|Command line interpreter|date=February 2007}}
[[Image:bash_screenshot.png|thumb|300px|Screenshot of a sample [[Bash]] session, taken on [[Gentoo Linux]].]]
[[Image:MS-DOS 6.22 dir screenshot.png|right|thumb|300px|Screenshot of the [[MS-DOS]] command line interface.]]
[[Image:Aux.jpeg|thumb|300px|Screenshot of [[Apple Computer]]'s CommandShell in [[A/UX]] 3.0.1.]]
[[Image:PowerShell.PNG|thumb|300px|Screenshot of [[Windows PowerShell]] RC 1, running under [[Windows Vista]]]]
 
[[en:Command line interface]]
Antaramuka Barisan Arahan '''CLI''' merupakan satu cara berinteraksi dengan sesuatu [[sistem pengendalian]]. CLI ini boleh jadi terminal bentuk teks atau terminal berbentuk ''emulator'' bahkan mungkin juga dalam bentuk cengkerang kawalan jauh seperti [[PuTTY]].
 
--[[Pengguna:Helmi|helmi]] 13:55, 1 Julai 2007 (UTC)
 
The concept of the CLI originated when [[teleprinter|teletype]] machines (TTY) were connected to computers in the [[1950s]], and offered results on demand, compared to 'batch' oriented mechanical [[punch card]] input technology. Dedicated text-based [[cathode ray tube|CRT]] terminals followed, with faster interaction and more information visible at one time, then [[computer terminal|graphical terminals]] enriched the visual display of information. Currently personal computers encapsulate both functions in software.
 
The CLI continues to [[coevolve]] with [[graphical user interface]]s (GUIs) like those provided by [[Microsoft Windows]], [[Mac OS]] and the [[X Window System]]. In some applications, such as [[MATLAB]], a CLI is integrated with the GUI, with the benefits of both. <!-- A minority of computer users prefer to use CLIs, because they feel that CLIs provide an environment with enhanced productivity{{Fact|date=February 2007}}. CLIs remain extremely popular for embedded systems, such as network devices{{Fact|date=February 2007}}.-->
 
==Usage== <!-- Who uses CLIs vs. Where CLIs are used? -->
 
A CLI is used whenever a large vocabulary of commands or queries, coupled with a wide (or arbitrary) range of options, can be entered more rapidly as text than with a pure GUI.
 
CLIs are often used by programmers and system administrators, in engineering and scientific environments, and by technically advanced personal computer users. CLIs are also popular among people with visual disability, since the commands and feedbacks can be displayed using [[Braille]]-displays. {{Fact|date=February 2007}}.
 
A program that implements such a text interface is often called a [[command line interpreter]] or [[shell (computing)|shell]]. Examples include the various [[Unix shell]]s (sh, ksh, csh, tcsh, bash, etc.), the historical [[CP/M]], and [[DOS]]'s [[COMMAND.COM]], the latter two based heavily on [[Digital Equipment Corporation|DEC's]] [[RSX-11|RSX]] and [[RSTS/E|RSTS]] CLIs.
 
<!-- specific products should move to a different section -->
In November 2006, [[Microsoft]] released version 1.0 of [[Windows PowerShell]] (formerly codenamed ''Monad''), which combined features of traditional Unix shells with their object-oriented [[.NET Framework]]. <!--NOT NPOV Windows' current CLI programs like COMMAND.COM and [[Windows Script Host]] are commonly considered inadequate or insecure.--> [[MinGW]] and [[Cygwin]] are [[open source]] packages for Windows that offer a Unix like CLI. Microsoft provides [[MKS Inc.]]'s [[Korn shell|ksh]] implementation ''MKS Korn shell'' for Windows through their [[Microsoft Windows Services for UNIX|Services for UNIX]] add-on.
 
The latest versions of the [[Macintosh]] operating system are based on a variation of UNIX called [[Darwin (operating system)|Darwin]]. On these computers, users can access a UNIX-like command line interface called [[Terminal (application)|Terminal]] found in the <tt>/Applications/Utilities</tt> folder.
 
[[Image:MATLAB screenshot showing sobel filtering of bitmap graphics.png|right|thumb|300px|Screenshot of the [[MATLAB]] 6.5 command line interface and GUI.]]
Some applications provide both a CLI and a GUI. The engineering/scientific numerical computation package [[MATLAB]] provides no GUI for some calculations, but the CLI can handle any calculation. The three-dimensional-modelling program [[Rhinoceros 3D]] (used to design the cases of most cell phones, as well as thousands of other industrial products) provides a CLI (whose language, by the way, is distinct from Rhino's scripting language). In some computing environments, such as the [[Oberon operating system|Oberon]] or [[Smalltalk]] user interface, most of the text which appears on the screen may be used for giving commands.
 
==Anatomy of a CLI==
 
A CLI can generally be considered as consisting of [[syntax]] and [[semantics]]. The ''syntax'' is the grammar that all commands must follow. In the case of [[Operating Systems]] (OS), [[MS-DOS]] and [[UNIX]] each define their own set of rules that all commands must follow. In the case of [[embedded systems]], each vendor, such as [[Nortel]], [[Juniper Networks]] or [[Cisco Systems]], defines their own proprietary set of rules that all commands within their CLI conform to. These rules also dictate how a user navigates through the system of commands. The ''semantics'' define what sort of operations are possible, and on what sort of data these operations can be performed.
 
Two different CLIs may agree on either syntax or semantics, but it is only when they agree on both that they can be considered sufficiently similar to allow users to use both CLIs without needing to relearn anything as well as enable re-use of scripts.
 
A simple CLI will display a prompt, accept a "command line" typed by the user terminated by the [[Enter key]], then execute the specified command and provide textual display of results or error messages. Advanced CLIs will validate, interpret and parameter-expand the command line before executing the specified command, and optionally capture or redirect its output.
 
Unlike a button or menu item in a GUI, a command line is typically self-documenting, stating exactly what the user wants done. In addition, command lines usually include many [[defaults]] that can be changed to customize the results. Useful command lines can be saved by assigning a [[character string]] or [[Alias (Unix shell)|alias]] to represent the full command, or several commands can be grouped to perform a more complex sequence &mdash; for instance, compile the program, install it, and run it &mdash; creating a single entity, called a command procedure or script which itself can be treated as a command. These advantages mean that a user must figure out a command or series of commands only once, because they can be saved, to be used again.
 
The commands given to a CLI are often of the form
 
:<code>[doSomething] [how] [toFiles]</code>
 
or
 
:<code>[doSomething] [how] [sourceFile] [destinationFile]</code>
 
or
 
:<code>[doSomething] [how] < [inputFile] > [outputFile]</code>
 
or
 
:<code>[doSomething] [how] | [doSomething] [how] | [do Something] [how] > [outputFile]</code>
 
''doSomething'' is, in effect, a [[verb]], ''how'' an [[adverb]] (for example, should the command be executed "verbosely" or "quietly") and ''toFiles'' an object or objects (typically one or more files) on which the command should act. The '>' in the second example is a redirection [[Operator (programming)|operator]], telling the command line interpreter to send the output of the command not to the screen but to the file named on the right of the '>'. Another redirection operator is the [[Vertical bar|pipe]] ('|'), which tells the CLI to use the output of one command as the input to the next command; this "operator-stream" mechanism can be very powerful.
 
=== CLI and Resource Protection ===
 
<!-- sorry, this section is awful. It's better now, and I'll find cites later. --Lexein -->
In some CLIs, the commands issued are not coupled to any conceptual place within a command hierarchy. A user can specify relative or absolute paths to any command or data. Examples of this include MS-DOS and UNIX/Windows, which provide forms of a [[chdir|change directory]] command which allows access to any directory in the system. Protection of resources is provided by a system of resource ownership by privileged groups, and password-protected user accounts which are members of specific groups. MS-DOS provides no such resource protection.
 
Other CLIs (such as those in routers) limit the set of commands that a user can perform to a subset, determined by location within a command hierarchy, grouped by association with security, system, interface, etc. The location within this hierarchy and the options available are often referred to as a mode. In these systems the user might traverse through a series of sub-hierarchies, each with their own subset of commands. For example, if the CLI had two modes called ''interface'' and ''system'', the user would enter the word 'interface' at the command prompt and then enter an interface mode, where a certain subset of commands and data are available. At this point system commands are not accessible and would not be accessible until the user explicitly exits the interface mode.
 
===Command prompt===<!-- This section is linked from [[Z shell]] -->
 
A command prompt (or just ''prompt'') is a sequence of (one or more) characters used in a command line interface to indicate readiness to accept commands. Its intent is to literally [[Wiktionary:prompt|prompt]] the user to take action. A prompt usually ends with one of the characters '''$''', '''%''', '''#''', ''':''', '''&gt;''' and often includes other information, such as the path of the current [[working directory]].
 
It is common for prompts to be modifiable by the user. Depending on the environment, they may include colors, special characters, and other elements like the current time, in order, for instance, to make the prompt more informative or visually pleasing, to distinguish sessions on various machines, or to indicate the current level of nesting of commands.
 
In DOS's COMMAND.COM and in the Windows command line interpreter [[cmd.exe]] the prompt is modifiable by issuing a <code>prompt</code> command or by changing the value of the <code>%PROMPT%</code> [[environment variable]]. The default <code>C:\></code> style is obtained, for instance, with "<code>prompt $P$G</code>".
 
On many [[Unix]] systems, the <code>$PS1</code> variable can be used, although other variables also may have an impact on the prompt (depending on what [[Unix shell|shell]] is being used). In the [[bash]] shell, a prompt of the form
:<code>[time] user@host: work_dir $</code>
could be set by issuing the command
:<code>export PS1='[\t] \u@\H: $(pwd) $'</code>
 
In [[zsh]] the $RPROMPT variable controls an optional "prompt" on the right hand side of the display. It is not a real prompt in that the location of text entry does not change. It is used to display information on the same line as the prompt, but right justified.
 
==Quotes==
 
{{quotation|"IBM wanted [[CP/M]] prompts. It made me throw up."|[[Tim Paterson]] (Author of [[86-DOS]]) <ref name="The Roots of DOS">{{cite web
|url=http://www.patersontech.com/Dos/Softalk/Softalk.html
|title="The Roots of DOS"
|year=[[1983]]
|accessdate=2007-06-18
|last=Hunter
|first=David
}}</ref>}}
 
{{quotation|"It was a mistake to think that GUIs ever would, could, or even should, eliminate CLIs."|[[Jeffrey Snover]] (Architect of [[Windows PowerShell]]) <ref name="Windows PowerShell Team Blog">{{cite web
|url=http://blogs.msdn.com/powershell/archive/2007/05/10/tui-the-ultimate-user-interface.aspx
|title=Windows PowerShell Team Blog
|publisher=Microsoft
|date=[[May 10]] [[2007]]
|accessdate=2007-05-10
|last=Snover
|first=Jeffrey
}}</ref>}}
 
==References==
<references />
 
==See also==
*[[Command line interpreter]]
*[[In the Beginning...was the Command Line]]
*[[Graphical_user_interface#Graphical_user_interfaces_compared_to_command_line_interfaces|GUI vs. CLI]]
*[[Scripting language]]
*[[Shell (computing)]]
 
==External links==
*[http://www.linux-command.com/ Linux Command Line] — a list of unix shell commands.
*[http://www.commandline.org.uk Command Line Warriors] — an open site about Command Line Computing.
* The Interaction-Design.org Encyclopedia entry on [http://www.interaction-design.org/encyclopedia/interaction_styles.html Interaction Styles, comparing Command Line Interfaces with other Interaction Styles]
*[http://www.igeek.com/articles/OS/CommandLines.txt Command lines versus GUIs]
*[http://commandwindows.com The Windows XP Command Line, Batch Files, and Scripting]
*[http://getpot.sourceforge.net/ "GetPot. Object oriented command line parsing."] Library available for C++, Python, Java, and Ruby.
*[http://te-code.sourceforge.net/article-20041121-cli.html "Object-Oriented Command Line Interfaces"] — Article describing the use of the TE-Common CLI library for Java (also available for .NET).
*[http://www.php-cli.com/ PHP Command Line Interface] — All about PHP CLI SAPI (using PHP in command line).
* [http://www.voidspace.org.uk/python/articles/command_line.shtml - Setting up the console for Windows] - A basic guide to setting up and using the command line for Windows.
*[http://www.osnews.com/story.php/6282/The-Command-Line--The-Best-Newbie-Interface/ The Command Line -- The Best Newbie Interface?] -- essay/memoir alleging/demonstrating that the CLI is actually more intuitive than the GUI, at least for adult newbies.
*[http://linux.byexamples.com/ Linux By Examples] - Explain every GNU/Linux command by examples.
*[http://www.pixelbeat.org/cmdline.html Linux Command line tips] - Linux command lines for common operations.
*[http://www.nanopac.com/PowerBraille.htm Braille Monitors] - Device to display CLI as Braille-script.
 
[[Category:User interface]]
[[Category:Software engineering]]
[[Category:Software architecture]]
 
[[cs:Příkazový řádek]]
[[de:Kommandozeile]]
[[es:Línea de comandos]]
[[fr:Interface en ligne de commande]]
[[ko:명령 줄 인터페이스]]
[[hu:Parancssoros felhasználói felület]]
[[nl:Opdrachtregelinterface]]
[[ja:キャラクターユーザインターフェース]]
[[pl:Wiersz poleceń]]
[[pt:Interface de linha de comando]]
[[ru:Интерфейс командной строки]]
[[sk:Príkazový riadok]]
[[fi:Komentoliittymä]]
[[zh:命令行界面]]