Command language

Updated: 10/07/2019 by Computer Hope

Sometimes called a command script, a command language is used to execute 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 commands, their functionality is limited to what's available at the command line making them easier to learn.

Below is an 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.
cd\window\temp
del *.* /q

Below is an example of a Perl script that performs a similar task as the batch file example, but with more sophistication. In this example, the 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";
}
close(mylog);

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 similar. However, scripts or programs offer the user the ability to perform many more commands that would otherwise be executed at the prompt.

Command, Language, Programming terms, Script