Command language

Updated: 04/26/2017 by Computer Hope

Sometimes referred to as a command script, a command language is a language used for executing a series of commands that would otherwise be executed at the prompt. A good example of a command language is Microsoft Windows batch files. Although command languages are useful for executing a series of commands, their functionality is limited to what is available at the command line which can make them easier to learn.

Below is a basic example of a Microsoft Windows batch file that deletes all the files in the Windows temp directory.

REM Delete Windows temp files.
echo Deleting Windows temp files.
del *.* /q

Below is a basic example of a Perl script that could be run in Microsoft Windows that performs a similar task to the above batch file example, but with some more sophistication. In this example, this script not only deletes the files, but creates a log containing information about each file deleted.

# Delete Windows files and log results into log.txt
my (@files, $files);
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $timeoffset);
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime;
$year = $year + 1900;

@files = `dir /b c:\windows\temp`;

open(mylog, ">>log.txt") || print "ERROR: $!";
foreach $files (@files) {
$files =~ s/\n//g;
system("del c\:\\windows\\temp\\$files /q");
print "Deleting $files at $hour:$min:$sec on $mon/$mday/$year\n";
print mylog "Deleting $files at $hour:$min:$sec on $mon/$mday/$year\n";

Advantages of command languages

  • Very easy for all types of users to write.
  • Do not require the files to be compiled.
  • Easy to modify and make additional commands.
  • Very small files.
  • Do not require any additional programs or files that are not already found on the operating system.

Disadvantages of command languages

  • Can be limited when comparing with other programming languages or scripting languages.
  • May not execute as fast as other languages or compiled programs.
  • Some command languages often offer little more than using the commands available for the operating system used.

In conclusion, scripts, and command languages are very similar. However, scripts or programs offer the user the ability to perform many more than just commands that would otherwise be executed at the prompt.

Command, Language, Programming terms, Script