![]() | ![]() | |||||||||||||||
|
External CommandsRunning External CommandsThe purpose of a shell script is, ultimately, to execute shell commands. Any command not understood by AdaScript as a command is assumed to be a shell command. For example, => echo will run the Linux/UNIX echo command and print a blank line to the screen, the same as new_line in the text_io package. Command ParametersCommands are accepted in one of two different formats. If the command is followed by a "(", the parameters are expected to be in AdaScript format with each parameter separated by a comma (","). These parameters may be any legitimate AdaScript expression and no shell quote removal or file globbing is performed. => ls( "spar.adb" ) If the command is not followed by a "(", the parameters are expected to be in Bourne shell format. This is provided for convenience in interactive sessions. The parameters are shell "words" separated by spaces. Each word has file globbing performed. The words may be enclosed in double quotes to allow embedded spaces, or single quotes to inhibit file globbing. Special characters may also be escaped with backslashes. => ls b*.adb For information on reading Bourne shell arguments, see Command Argument Shortcuts. Variable ExpansionSparForte can insert the values of variables using BASH-style "$"
substitutions. "ls $HOME" will show the contents of your home
directory. See this page for details on various expansions. Quoting CommandsCommand names containing space characters can be quoted with double quotes. => "inventory report" When pragma ada_95 is used, shell commands must only use the AdaScript parameter format. Running Commands in the BackgroundExternal commands can be run in the background using an ampersand ("&") at the end of the command. With AdaScript parameters, place the ampersand after the closing parenthesis. The jobs command displays the status of any outstanding background commands. The built-in shell commands are listed in a section above. when a Linux command conflicts with a built-in command, the Linux command can be executed using the command command. Capturing Command OutputThe results of a command can be captured as a string using backquotes. The commands should be ended with a semi-colon. Commands appearing in backquotes will be syntax checked along with the rest of the commands in a script. => date : string := `date;` If there is a trailing line feed (or carriage return/line feed for Windows) it will be removed. Standard input, standard error and standard output can be redirected using the Text_IO package. |
![]() Block Statements and Subprograms |
![]() |
![]() |