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

_____________________________________________________________________________________________________________________

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

 

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