This is a discussion on DOS Host Call via Java SP within the Oracle Database forums, part of the Database Server Software category; --> Please help me out..thanks The code below worked fine under *nix (9i) where instead of "c:/winnt/system32/cmd", I had "/bin/sh". ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Please help me out..thanks The code below worked fine under *nix (9i) where instead of "c:/winnt/system32/cmd", I had "/bin/sh". But under 8i/W2K, it's not carrying out my commands: CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Util" AS import java.io.*; import java.lang.*; public class Util extends Object { public static int RunThis(String args) { Runtime rt = Runtime.getRuntime(); int rc = -1; try { String[] cmd = {"c:/winnt/system32/cmd", "/c", args}; Process p = Runtime.getRuntime().exec(cmd); rc = p.waitFor(); } catch (Exception e) { e.printStackTrace(); rc = -1; } finally { return rc; } } } / CREATE OR REPLACE FUNCTION run_host_cmd(p_cmd IN VARCHAR2) RETURN NUMBER AS LANGUAGE JAVA NAME 'Util.RunThis(java.lang.String) return integer'; / CREATE OR REPLACE PROCEDURE RC(p_cmd IN VARCHAR2) AS x NUMBER; BEGIN x := run_host_cmd(p_cmd); END; / SQL> exec rc('del C:\temp\foo.pdf'); PL/SQL procedure successfully completed ---- BUT C:\temp\foo.pdf' is NOT deleted |
| |||
| Housen wrote: > Please help me out..thanks > > The code below worked fine under *nix (9i) where instead of > "c:/winnt/system32/cmd", I had "/bin/sh". > But under 8i/W2K, it's not carrying out my commands: <snip> Did you try it with backslashes? "c:\winnt\system32\cmd" |
| |||
| I started with "c:\winnt\system32\cmd" but got "ORA-29536 badly formed source:... when compiling, so I switched to "/" "Bricklen" . > > Please help me out..thanks > > > > The code below worked fine under *nix (9i) where instead of > > "c:/winnt/system32/cmd", I had "/bin/sh". > Did you try it with backslashes? > "c:\winnt\system32\cmd" |
| ||||
| Thanks Took your suggestion and recompiled - no problem , now works ! "Peter Sylvester" <peters_no_spam_please@mitre.org> wrote in message news:c5higk$doa$1@newslocal.mitre.org... > How about: > "c:\\winnt\\system32\\cmd" > > --Peter > > ricklen wrote: > > Housen wrote: > > > >> I started with "c:\winnt\system32\cmd" but got > >> "ORA-29536 badly formed source:... > >> when compiling, > >> so I switched to "/" > > > > ahh |