Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Libraries AES ARC4 Array ASN.1 Bigfile Bigint Bigrat Bin32 Bin64 Bitdata Bitmapfont Bitset Bitsetof Boolean Browser Bstring Bytedata Cards Category CC config Cgi Cgi dialog Char Charsets Cipher Clib_file Color CLI Commands Complex Console Crc32 Deflate DES Dialog Dir Draw Duration Echo Editline Enable_input Enable_io Enable_output Encoding Environment External_file File File system Float Font Forloop Ftp Getf Gethttp Gethttps Graph Graph_file Gzip Hash Hashsetof Hmac Html_ent Httpserv Idxarray Image Inflate Inflate file Inifile Integer Keybd Line Listener LZW Make Math Msgdigest Null_file Osfiles Picture utility Pixmap_file Pixmapfont PKCS #1 Poll Process Progs Propertyfile Rational Reference Ref_list Scanfile Scanstri Set Shell Smtp Sockbase Socket SQL base Stdio Strifile String Stritext Subrange Tar Text Time TLS/SSL Triple DES Unicode Utf16 Utf8 Vectorfont 3D Vector Wildcard Window Wrinum X.509 Xmldom Xml_ent Zip
Libraries
Shell Source Code
 previous   up   next 

Function Summary
integer
shell (in string: command, in string: parameters)
Use the shell to execute a command with parameters.
void
cmd_sh (in string: command, in string: parameters)
Use the shell to execute a command with parameters.
integer
shell (in string: cmdAndParams)
Executes a command using the shell of the operating system.
void
cmd_sh (in string: cmdAndParams)
Executes a command using the shell of the operating system.
string
shellEscape (in string: stri)
Convert a string, such that it can be used as shell parameter.
string
toOsPath (in string: standardPath)
Convert a standard path to the path of the operating system.
string
toShellPath (in string: path)
Convert a standard path such that it can be used as shell parameter.
file
popen (in string: command, in string: parameters, in string: mode)
Open a pipe to a shell command with parameters.
file
popen (in string: cmdAndParams, in string: mode)
Open a pipe to a shell command.
file
popen (in string: command, in array string: paramList, in string: mode)
Open a pipe to a shell command with a paramList.
void
close (in popen_file: aPipe)
Wait for the process associated with aPipe to terminate.
file
popen8 (in string: command, in string: parameters, in string: mode)
Open an UTF-8 encoded pipe to a shell command with parameters.
file
popen8 (in string: cmdAndParams, in string: mode)
Open an UTF-8 encoded pipe to a shell command.
file
popen8 (in string: command, in array string: paramList, in string: mode)
Open an UTF-8 encoded pipe to a shell command with a paramList.
void
close (in popen8_file: aPipe)
Wait for the process associated with aPipe to terminate.

Function Detail

shell

const func integer: shell (in string: command, in string: parameters)

Use the shell to execute a command with parameters. Parameters which contain a space must be enclosed in double quotes (E.g.: shell("aCommand", "\"par 1\" par2"); ). The commands supported and the format of the parameters are not covered by the description of the shell function. Due to the usage of the operating system shell and external programs, it is hard to write portable programs, which use the shell function.

Parameters:
command - Name of the command to be executed. A path must use the standard path representation.
parameters - Space separated list of parameters for the command, or "" when there are no parameters.
Returns:
the return code of the executed command or of the shell.

cmd_sh

const proc: cmd_sh (in string: command, in string: parameters)

Use the shell to execute a command with parameters. Parameters which contain a space must be enclosed in double quotes (E.g.: cmd_sh("aCommand", "\"par 1\" par2"); ). The commands supported and the format of the parameters are not covered by the description of the cmd_sh function. Due to the usage of the operating system shell and external programs, it is hard to write portable programs, which use the cmd_sh function.

Parameters:
command - Name of the command to be executed. A path must use the standard path representation.
parameters - Space separated list of parameters for the command, or "" when there are no parameters.

shell

const func integer: shell (in string: cmdAndParams)

Executes a command using the shell of the operating system. The command path must use the standard path representation. Spaces in the command must be preceded by a backslash (E.g.: shell("do\\ it"); ). Alternatively the command can be enclosed in double quotes (E.g.: shell("\"do it\""); ). Command parameters containing a space must be enclosed in double quotes (E.g.: shell("do_it \"par 1\" par2"); ). The commands supported and the format of the parameters are not covered by the description of the shell function. Due to the usage of the operating system shell and external programs, it is hard to write portable programs, which use the shell function.

Parameters:
cmdAndParams - Command to be executed and optional space separated list of parameters. Command and parameters must be space separated.
Returns:
the return code of the executed command or of the shell.

cmd_sh

const proc: cmd_sh (in string: cmdAndParams)

Executes a command using the shell of the operating system. The command path must use the standard path representation. Spaces in the command must be preceded by a backslash (E.g.: cmd_sh("do\\ it"); ). Alternatively the command can be enclosed in double quotes (E.g.: cmd_sh("\"do it\""); ). Command parameters containing a space must be enclosed in double quotes (E.g.: cmd_sh("do_it \"par 1\" par2"); ). The commands supported and the format of the parameters are not covered by the description of the cmd_sh function. Due to the usage of the operating system shell and external programs, it is hard to write portable programs, which use the cmd_sh function.

Parameters:
cmdAndParams - Command to be executed and optional space separated list of parameters. Command and parameters must be space separated.

shellEscape

const func string: shellEscape (in string: stri)

Convert a string, such that it can be used as shell parameter. The function adds escape characters or quotations to a string. The result is useable as parameter for the functions shell, cmd_sh, popen and popen8. Shell parameters must be escaped individually. Afterwards escaped parameters are joined to a space separated list of parameters.

Returns:
a string which can be used as shell parameter.
Raises:
MEMORY_ERROR - Not enough memory to convert 'stri'.

toOsPath

const func string: toOsPath (in string: standardPath)

Convert a standard path to the path of the operating system. The result must be escaped with shellEscape to be useable as parameter for the functions shell, cmd_sh, popen and popen8.

Parameters:
standardPath - Path in the standard path representation.
Returns:
a string containing an operating system path.
Raises:
MEMORY_ERROR - Not enough memory to convert standardPath.
RANGE_ERROR - standardPath is not representable as operating system path.

toShellPath

const func string: toShellPath (in string: path)

Convert a standard path such that it can be used as shell parameter. The result is useable as parameter for the functions shell, cmd_sh, popen and popen8. Shell parameters must be converted individually. Afterwards converted parameters are joined to a space separated list of parameters.

Parameters:
standardPath - Path in the standard path representation.
Returns:
a string containing an escaped operating system path.
Raises:
MEMORY_ERROR - Not enough memory to convert standardPath.
RANGE_ERROR - standardPath is not representable as operating system path.

popen

const func file: popen (in string: command, in string: parameters, in string: mode)

Open a pipe to a shell command with parameters. The command reads, respectively writes with Latin-1 encoding. Parameters which contain a space must be enclosed in double quotes (E.g.: popen("aCommand", "\"par 1\" par2", "r"); ). The function shellEscape converts a string, such that it can be used as parameter for popen (E.g.: popen("aCmd", shellEscape("par 1") & " par2", "r"); ). The commands supported and the format of the parameters are not covered by the description of the popen function. Due to the usage of the operating system shell and external programs, it is hard to write portable programs, which use the popen function.

Parameters:
command - Name of the command to be executed. A path must use the standard path representation.
parameters - Space separated list of parameters for the command, or "" when there are no parameters.
mode - A pipe can be opened with the binary modes "r" (read) and "w" (write) or with the text modes "rt" (read) and "wt" (write).
Returns:
the pipe file opened, or STD_NULL if it could not be opened.
Raises:
RANGE_ERROR - command is not representable as operating system path, or mode is illegal.

popen

const func file: popen (in string: cmdAndParams, in string: mode)

Open a pipe to a shell command. The command reads, respectively writes with Latin-1 encoding. Spaces in the command must be preceded by a backslash (E.g.: popen("do\\ it"); ). Alternatively the command can be enclosed in double quotes (E.g.: popen("\"do it\""); ). Command parameters containing a space must be enclosed in double quotes (E.g.: popen("do_it \"par 1\" par2"); ). The commands supported and the format of the parameters are not covered by the description of the popen function. Due to the usage of the operating system shell and external programs, it is hard to write portable programs, which use the popen function.

Parameters:
cmdAndParams - Command to be executed and optional space separated list of parameters. Command and parameters must be space separated.
mode - A pipe can be opened with the binary modes "r" (read) and "w" (write) or with the text modes "rt" (read) and "wt" (write).
Returns:
the pipe file opened, or STD_NULL if it could not be opened.
Raises:
RANGE_ERROR - The command is not representable as operating system path, or mode is illegal.

popen

const func file: popen (in string: command, in array string: paramList, in string: mode)

Open a pipe to a shell command with a paramList. The command reads, respectively writes with Latin-1 encoding.

Parameters:
command - Name of the command to be executed. A path must use the standard path representation.
paramList - Array of argument strings passed to the command. It is not necessary to quote the parameters, since this function takes care of that.
mode - A pipe can be opened with the binary modes "r" (read) and "w" (write) or with the text modes "rt" (read) and "wt" (write).
Returns:
the pipe file opened, or STD_NULL if it could not be opened.
Raises:
RANGE_ERROR - command is not representable as operating system path, or mode is illegal.

close

const proc: close (in popen_file: aPipe)

Wait for the process associated with aPipe to terminate.

Parameters:
aFile - Pipe to be closed (created by 'popen').
Raises:
FILE_ERROR - A system function returned an error.

popen8

const func file: popen8 (in string: command, in string: parameters, in string: mode)

Open an UTF-8 encoded pipe to a shell command with parameters. The command reads, respectively writes with UTF-8 encoding. Parameters which contain a space must be enclosed in double quotes (E.g.: popen8("aCommand", "\"par 1\" par2", "r"); ). The function shellEscape converts a string, such that it can be used as parameter for popen (E.g.: popen8("aCmd", shellEscape("par 1") & " par2", "r"); ). The commands supported and the format of the parameters are not covered by the description of the popen8 function. Due to the usage of the operating system shell and external programs, it is hard to write portable programs, which use the popen8 function.

Parameters:
command - Name of the command to be executed. A path must use the standard path representation.
parameters - Space separated list of parameters for the command, or "" when there are no parameters.
mode - A pipe can be opened with the binary modes "r" (read) and "w" (write) or with the text modes "rt" (read) and "wt" (write).
Returns:
the pipe file opened, or STD_NULL if it could not be opened.
Raises:
RANGE_ERROR - command is not representable as operating system path, or mode is illegal.

popen8

const func file: popen8 (in string: cmdAndParams, in string: mode)

Open an UTF-8 encoded pipe to a shell command. The command reads, respectively writes with UTF-8 encoding. Spaces in the command must be preceded by a backslash (E.g.: popen8("do\\ it"); ). Alternatively the command can be enclosed in double quotes (E.g.: popen8("\"do it\""); ). Command parameters containing a space must be enclosed in double quotes (E.g.: popen8("do_it \"par 1\" par2"); ). The commands supported and the format of the parameters are not covered by the description of the popen8 function. Due to the usage of the operating system shell and external programs, it is hard to write portable programs, which use the popen8 function.

Parameters:
cmdAndParams - Command to be executed and optional space separated list of parameters. Command and parameters must be space separated.
mode - A pipe can be opened with the binary modes "r" (read) and "w" (write) or with the text modes "rt" (read) and "wt" (write).
Returns:
the pipe file opened, or STD_NULL if it could not be opened.
Raises:
RANGE_ERROR - The command is not representable as operating system path, or mode is illegal.

popen8

const func file: popen8 (in string: command, in array string: paramList, in string: mode)

Open an UTF-8 encoded pipe to a shell command with a paramList. The command reads, respectively writes with UTF-8 encoding.

Parameters:
command - Name of the command to be executed. A path must use the standard path representation.
paramList - Array of argument strings passed to the command. It is not necessary to quote the parameters, since this function takes care of that.
mode - A pipe can be opened with the binary modes "r" (read) and "w" (write) or with the text modes "rt" (read) and "wt" (write).
Returns:
the pipe file opened, or STD_NULL if it could not be opened.
Raises:
RANGE_ERROR - command is not representable as operating system path, or mode is illegal.

close

const proc: close (in popen8_file: aPipe)

Wait for the process associated with aPipe to terminate.

Parameters:
aPipe - UTF-8 encoded pipe to be closed (created by 'popen8').
Raises:
FILE_ERROR - A system function returned an error.


 previous   up   next