2 Ways to Run / Execute OS (Unix, Linux, Windows) Commands, Shell Script from SQLPLUS or SQL prompt

advertisements

_____________________________________________________________________________________________________________________

The Eucharistic Miracles of the World
You can use either ! or host keyword to execute OS commands or to run shell script from the sqlplus / sql prompt. Here are some examples for OS command execution

SQL> !pwd
/home/oracle

SQL> host pwd
/home/oracle

SQL> host date
Wed Mar  1 00:33:47 EST 2017

SQL> !date

Shell Script Execution I have a sample shell script file here called New_Shell.sh

$ cat New_Shell.sh
ls -ltr
sleep 10

Wed Mar  1 00:33:50 EST 2017
$ vi New_Shell.sh
Change the permissions to executable mode.
$ chmod 744 New_Shell.sh
advertisements
 
Now you can run the shell script using either ! or host command.

SQL> !./New_Shell.sh
total 4
-rwxr--r-- 1 oracle oinstall 18 Mar  1 00:29 New_Shell.sh

SQL> host ./New_Shell.sh
total 4
-rwxr--r-- 1 oracle oinstall 18 Mar  1 00:29 New_Shell.sh

_____________________________________________________________________________________________________________________

Website Stats

0 comments:

Post a Comment

Labels

Oracle (629) Script (86) General (77) Unix (47) Blog (23) Technology (19) gadget (6) games (6) Business (3) OCI (3) SQL* Loader (3) Datapump (2)
 

acehints.com Copyright 2011-23 All Rights Reserved | Site Map | Contact | Disclaimer