.bash_history not recording host/os command executed from >SQL prompt
Red Hat Enterprise Linux Server release 6.7 (Santiago) is the OS version
$ sqlplus
SQL> !hostname -i
10.3.10.197
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@exaoem01 ~]$ history
...........................
........................
1012 sqlplus
1013 history
From the above example It is evident that any os commands executed from "SQL> " prompt are not recorded not sure why. How can I audit or force these commands to be visible in .bash_history . Appreciate your insight.
Regards/Hissam
Responses
as sqlplus is launching its own process and you are executing those commands inside that process, bash is not aware of their execution.
Maybe you are looking for something like this
Hissam,
See Will's post above. One thought though, let's say you know you're about to begin a procedure on a server you wish to keep a record of for later reference, perhaps to document steps or something. If you do know this in advance, you can use script -a /path/to/file.txt which will record all commands and output until the time you execute a ctrl c to interrupt the recording process. Read the man page for the usage of script -a /path/to/some/file.txt
Excerpt of man page:
DESCRIPTION
script makes a typescript of everything displayed on your terminal.
It is useful for students who need a hardcopy record of an
interactive session as proof of an assignment, as the typescript file
can be printed out later with lpr(1).
If the argument file is given, script saves the dialogue in this
file. If no filename is given, the dialogue is saved in the file
typescript
Different shells operate in different history contexts. While you're using bash to launch the sqlplus shell, what happens within sqlplus is opaque to bash. The sqlplus shell has its own history mechanisms you can leverage, but they are wholly separate from bash's.
You might look at some combination of sqlplus's hist and spool commands to save out your sql monitor's history to a file, but don't really know any other built-in methods for dumping history and (potentially) redirecting to disk. Note: the hist command was introduced in Oracle 12, I believe, so if you're using an older version of Oracle, you may be outta luck (for built-in tools).
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
