Home » SQL & PL/SQL » SQL & PL/SQL » Execute UNIX script from PL/SQL procedure
Execute UNIX script from PL/SQL procedure [message #46478] Thu, 10 June 2004 00:19 Go to next message
Irena
Messages: 3
Registered: May 2001
Junior Member
 I need execute unix script (csh/tcsh) from PL/SQL procedure.

Thanks.

 
Re: Execute UNIX script from PL/SQL procedure [message #46485 is a reply to message #46478] Thu, 10 June 2004 03:24 Go to previous messageGo to next message
Tak Tang
Messages: 142
Registered: May 2004
Senior Member
Oracle 7 - you need a daemon process to read commands from a dbms_pipe and execute them.

Oracle 8/9/10 - you could use and external procedure; java; maybe Com Automation if on windows; maybe use utl_tcp or utl_http to call a web page.
Re: Execute UNIX script from PL/SQL procedure [message #46534 is a reply to message #46478] Sat, 12 June 2004 03:04 Go to previous messageGo to next message
Ed Yin
Messages: 4
Registered: April 2004
Junior Member
Could you be more specific about this calling and system OS what you are using ? And maybe tell me what is the $HOME_DIR from where you are calling your sql scripts.
Re: Execute UNIX script from PL/SQL procedure [message #46535 is a reply to message #46534] Sat, 12 June 2004 03:10 Go to previous messageGo to next message
Ed Yin
Messages: 4
Registered: April 2004
Junior Member
i just added some manual docs in advance:

HO[[ST]] [[ command ]]
HOST executes a host operating system command without leaving SQL*Plus.
command
is a host operating system command. Enter HOST without command t
display an operating system prompt. You can then enter multiple
operating system commands. To return to SQL*Plus, type LOGOFF,
EXIT, QUIT, or other command applicable to your operating system.

With some operating systems, you can use $ (VMS), ! (UNIX) or another
character instead of HOST. You may or may not have access to the HOST
command, depending on your operating system, and privileges assigned by
your system administrator.

SQL*Plus removes the SQLTERMINATOR (a semicolon by default) before the
HOST command is issued. A workaround for this is to add another
SQLTERMINATOR. See SET SQLTERMINATOR for more information on the
SQLTERMINATOR.
Re: Execute UNIX script from PL/SQL procedure [message #46536 is a reply to message #46478] Sat, 12 June 2004 12:08 Go to previous messageGo to next message
Barbara Boehmer
Messages: 8587
Registered: November 2002
Location: California, USA
Senior Member
The HOST command only works from SQL*Plus, but from PL/SQL, you can use some java:

Re: Execute UNIX script from PL/SQL procedure [message #436825 is a reply to message #46535] Mon, 28 December 2009 12:51 Go to previous messageGo to next message
lilo1234
Messages: 1
Registered: December 2009
Junior Member
Hi,

I am executing a simple unix command from the below pl/sql block.

begin
if (111111>5000)
then
DBMS_OUTPUT.PUT_LINE('Updates Exceeded the limit');
HOST
echo abc | mailx -s "updates exceeded the limit" 123@abcd.com
exit
return;
end if;
end;
/


I am getting the following erros

ERROR at line 7:
ORA-06550: line 7, column 3:
PLS-00103: Encountered the symbol "ECHO" when expecting one of the following:
:= . ( @ % ;
The symbol "( was inserted before "ECHO" to continue.
ORA-06550: line 7, column 23:
PLS-00114: identifier 'updates exceeded the limi' too long
ORA-06550: line 7, column 23:
PLS-00103: Encountered the symbol "updates exceeded the limi" when
expecting one of the following:
. ( * @ % & | - + / at mod remainder rem => ..
<an exponent (**)> ||
ORA-06550: line 8, column 3:
PLS-00103: Encountered the symbol "EXIT" when expecting one of the following:
:= . ( @ % ; not null range default character



I tried adding an addition semicolon (Wink it doesn't help.The above UNIX commands work great on sql prompt though.

SQL> HOST
[-/export/home/scmdata]:
$ echo abc | mailx -s "updates exceeded the limit" 123@abc.com
[-/export/home/scmdata]:
$ exit
SQL>


Can some one please help me with this.Thanks in advance.

Re: Execute UNIX script from PL/SQL procedure [message #436828 is a reply to message #436825] Mon, 28 December 2009 12:58 Go to previous messageGo to next message
Michel Cadot
Messages: 63818
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
HOST is a SQL*Plus command not a SQL or PL/SQL one.
So it does not work in PL/SQL block.

Regards
Michel
Re: Execute UNIX script from PL/SQL procedure [message #436839 is a reply to message #436825] Mon, 28 December 2009 15:26 Go to previous message
joy_division
Messages: 4618
Registered: February 2005
Location: East Coast USA
Senior Member
lilo1234 wrote on Mon, 28 December 2009 13:51
Hi,

I am executing a simple unix command from the below pl/sql block.


Can some one please help me with this.Thanks in advance.


If you search google with the subject line, you should be able to find plenty of examples.
Previous Topic: Result based on conditional where clause
Next Topic: Store big data into variable
Goto Forum:
  


Current Time: Fri Sep 30 22:46:46 CDT 2016

Total time taken to generate the page: 0.10420 seconds