Unix Technical Forum

DOS Host Call via Java SP

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". ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-23-2008, 08:33 AM
Housen
 
Posts: n/a
Default DOS Host Call via Java SP

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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-23-2008, 08:33 AM
Bricklen
 
Posts: n/a
Default Re: DOS Host Call via Java SP

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"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-23-2008, 08:33 AM
Housen
 
Posts: n/a
Default Re: DOS Host Call via Java SP

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"



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-23-2008, 08:33 AM
Bricklen
 
Posts: n/a
Default Re: DOS Host Call via Java SP

Housen wrote:

> I started with "c:\winnt\system32\cmd" but got
> "ORA-29536 badly formed source:...
> when compiling,
> so I switched to "/"

ahh
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-23-2008, 08:33 AM
Peter Sylvester
 
Posts: n/a
Default Re: DOS Host Call via Java SP

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-23-2008, 08:33 AM
Housen
 
Posts: n/a
Default Re: DOS Host Call via Java SP

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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:40 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com