In Oracle Forms, most logic is executed within the database or the application itself. However, sometimes developers need to interact with the operating system—for example, to run scripts, open external programs, or perform administrative tasks outside the form. Oracle Forms provides the HOST built-in for this purpose. This tutorial explains how to use the HOST built-in, its syntax, use cases, examples, limitations, and best practices.
What is the HOST Built-in?
The HOST built-in allows Oracle Forms to execute operating system commands from within a running form. When called, it passes the command string to the operating system shell and waits for the execution to complete.
It is especially useful when you want to:
- Run shell scripts or batch files.
- Execute database export/import utilities.
- Open text files, log files, or external applications.
- Automate administrative tasks that require operating system interaction.
Syntax of HOST
The general syntax of the HOST built-in is:
HOST (command_string, screen_flag);
- command_string: The operating system command you want to execute.
- screen_flag (optional): Determines how Forms handles the screen during execution.
- NO_SCREEN → Executes the command without clearing the Forms screen.
- FULL_SCREEN → Clears the Forms screen and shows command output.
If no flag is specified, the default is FULL_SCREEN.
Example: Running a Simple Command
BEGIN
HOST('dir', NO_SCREEN);
END;
On a Windows system, this will execute the dir command to list directory contents.
On Linux/Unix systems, you might write:
BEGIN
HOST('ls -l', NO_SCREEN);
END;
This will list files in the current directory without clearing the Forms screen.
Example: Running External Programs
1. Opening Notepad on Windows
BEGIN
HOST('notepad C:\temp\readme.txt', NO_SCREEN);
END;
This opens the file readme.txt in Notepad.
2. Running a Shell Script on Linux
BEGIN
HOST('/u01/app/scripts/process_data.sh', NO_SCREEN);
END;
This executes the shell script process_data.sh.
Blocking vs Non-Blocking Behavior
By default, HOST is blocking—Forms waits for the external process to finish before continuing execution. This can be problematic if the external command takes a long time.
To run commands asynchronously (non-blocking), developers usually call scripts that run in the background. For example, on Unix/Linux:
BEGIN
HOST('/u01/app/scripts/long_job.sh &', NO_SCREEN);
END;
The ampersand (&) ensures the script runs in the background, allowing Oracle Forms to continue.
Security Considerations
Using HOST introduces potential security risks because it allows execution of OS-level commands. Developers must:
- Avoid exposing HOST commands to end-users.
- Validate input parameters before passing them to HOST.
- Restrict usage only to trusted scripts and commands.
- Ensure proper operating system permissions are set for the Forms runtime user.
Limitations of HOST
- Platform Dependency
- The commands are OS-specific (
dirworks on Windows,lsworks on Linux).
- The commands are OS-specific (
- Blocking Execution
- Unless explicitly handled, Forms will pause until the external program finishes.
- Limited Error Handling
- HOST does not provide detailed return codes or logs from the external program.
- Performance Issues
- Frequent calls to HOST may slow down the form, especially if commands are resource-intensive.
- Deprecation in Web-Deployed Forms
- In client/server Forms, HOST works directly. In web-deployed Oracle Forms (Forms Services), HOST is restricted because execution happens on the application server, not the client machine.
Alternative: Using WEBUTIL for Client-Side Execution
In modern Oracle Forms (especially web-deployed versions), HOST cannot directly execute client-side programs. Instead, Oracle recommends using WEBUTIL.
Example using WebUtil’s CLIENT_HOST:
BEGIN
WEBUTIL_HOST.CLIENT_HOST('notepad C:\temp\readme.txt');
END;
This executes the command on the client machine, unlike HOST which runs on the server.
Best Practices for Using HOST
- Use only for essential tasks
- Avoid using HOST for things that can be handled by PL/SQL or built-in Forms functionality.
- Test across environments
- Ensure your HOST commands are compatible with both Windows and Unix/Linux if your application runs on multiple platforms.
- Handle background execution carefully
- For long-running scripts, run them asynchronously to avoid blocking the form.
- Secure access
- Restrict HOST usage to internal, controlled commands to prevent misuse.
- Use WEBUTIL for client-side tasks
- In web environments, rely on WEBUTIL for safer client interaction.
Conclusion
The HOST built-in in Oracle Forms is a powerful feature for running operating system commands and integrating external applications with Forms. It is particularly useful for batch processing, file operations, and administrative scripts. However, because it introduces security and performance considerations, it must be used carefully and preferably replaced with WEBUTIL for client-side operations in modern web-deployed Forms.
When applied correctly with best practices, HOST can greatly enhance the functionality of Oracle Forms by extending its reach beyond the database and into the operating system.

