Running a host command from servlet

Hi
I am trying to run some hostcommand/shell scripts from a servlet.Can any one tell me how to go about it.
Rgds,
Satya

this is very useful, I've been looking for a long time but nobody is able to answer me, even my tutor.
andrew

Similar Messages

  • How to run a HOST command from Report 2.5

    Hello everybody,
    I want to pass an unix command from a Report. I am running the report (Report 2.5) on an Unix server and I want to pass a unix host command inside the Before Report Trigger of the report. But Report2.5 is not recognising the HOST built-in. Is there is any way around?
    Thank in advance.
    Samujjwal Basu

    First off is that openssl command correct? Should it be this instead:
    openssl pkcs8 -inform der -nocrypt -in test.der -out result.pem
    Try out your openssl command within a command prompt so that you know that it works ok. I think the command line you specified waits on stdin (well it does for me).
    After that.....
    runtime.exec creates a Process object. If you do this:
    Process openssl = runtime.exec("....")
    then you can examine the return code from openssl to see the exit code - for instance if the input file does not exist then exit = 1. You can test for this with Java
    Alternatively you could get the stderr from the process and look inside it - if it is 0 length then all is good, if it has some text in there then it has likely failed. You could then throw an exception and include the stderr output in the exception messgae. You may need to experiment with this, runnig it first when openssl is happy then running it again when openssl is upset.
    M

  • How to run Unix Host commands from Database Triggers?

    Hi
    I need to create few directories in the Unix O/s under a specific directory (From a Database Trigger). And the directory names will be determined in the DB Trigger based on the data.
    I hope someone would have come across a requirement like this and will be able to help me out.
    Thanks.
    Mohan

    Hi Christopher
    How is it possible to use System calls from Triggers. Is it possible to use Runtime Libraries in DB Triggers.
    Thanks
    Mohan
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Christopher Racicot ([email protected]):
    Try using the system calls available in
    the C runtime library by calling an external
    C procedure from the trigger. We will be
    enhancing the support in UTL_FILE to address
    issues like this in an upcoming release,
    but for now an external procedure should
    do the trick.<HR></BLOCKQUOTE>
    null

  • Is it possible to run host command from SAP environment? How do you run?

    Hi
    Is it possible to run host command from SAP environment? How do you run?
    Thank You

    Hello Subhash
    You will more details in the following thread:
    Re: How to define command for SXPG_COMMAND_EXECUTE
    Regards
      Uwe

  • Host command from D2K Forms

    Am calling the sql loader (sqlldr73) using HOST command from D2K Forms 4.5.
    my code has following sequence,
    <sequence of stmts 1>
    Host(....);
    <sequence of stmts 2>
    the stmts(<sequence of stmts 2>) following the call to HOST commant should be executed only after successful execution of the sql loader.
    curently the sql loader and stmts(<sequence of stmts 2>) are running parallely
    Is there any work around?

    Hi,
    Better way to do it would be to write a batch / shell script with the sequence of statements you want to execute and call the batch file using the host command.
    Regards,
    Arun

  • How to run a DOS command from an Oracle form.

    How can I run a DOS command from an Oracle form (i.e. open the calculator located at c:\windows\system32\calc.exe)?

    first of all get the environment variable for the c:\windows\system32 direcotry for any of the windows
    you can use get variable from the ora env package
    now cancat the system32 variable with the calc.exe string
    now pass the string with host command as parameters
    this process will work for all type of windows.

  • Host Commands from Java

    Hello everyone,
    I'm trying to run openVMS host commands via Java using the code listed below, which essentially runs the following host commands, each in turn:
    terry :== "hello"
    sho sym terry
    sho log robin4
    I've tried a few other commands as well, but the ones which assign variables (such as the terry example above), never work, either producing no output as in the example above, or if I did
    define/group "hello" terry
    would produce:
    DCL-W-NOCOMD, no command on line - reenter with alphabetic first character
    So commands that don't print anything to the screen are the ones that are causing problems (they're just setting variables or what not).
    Does anyone have any ideas as to how to get these commands working via java? I really don't know what to think..I've tried checking the format of the commands I'm trying to do, and it's not down to that - the host command I'm running is right and works if done directly.
    Please help! Thank you so much in advance.
    Robin
    import java.io.*;
    public class Host {
    public static void executeCommand(String command) {
    String s = "hello";
    String s2 = "sho log robin4";
    String s3 = "assign/system "+command+"hello"+command+" robin5";
    try {
    String[] finalCommand;
    System.out.println(System.getProperty("os.name"));
    finalCommand = new String[3];
    finalCommand[0] = "terry :== \"hello\"";
    finalCommand[1] = "sho sym terry";
    finalCommand[2] = s2;
    for(int i = 0;i< finalCommand.length; i++){
    // Execute the command...
    final Process pr = Runtime.getRuntime().exec(finalCommand);
    // Capture output from STDOUT...
    BufferedReader br_in = null;
    try {
    br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    String buff = null;
    while ((buff = br_in.readLine()) != null) {
    System.out.println("stdout: " + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_in.close();
    } catch (IOException ioe) {
    System.out.println("Error printing process output.");
    ioe.printStackTrace();
    } finally {
    try {
    br_in.close();
    } catch (Exception ex) {}
    // Capture output from STDERR...
    BufferedReader br_err = null;
    try {
    br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
    String buff = null;
    while ((buff = br_err.readLine()) != null) {
    System.out.println("stderr: " + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_err.close();
    } catch (IOException ioe) {
    System.out.println("Error printing execution errors.");
    ioe.printStackTrace();
    } finally {
    try {
    br_err.close();
    } catch (Exception ex) {}
    catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage());

    User_resU wrote:
    Hello everyone,
    I'm trying to run openVMS host commands via Java using the code listed below, which essentially runs the following host commands, each in turn:
    terry :== "hello"
    sho sym terry
    sho log robin4
    1. Presumably this represents some sort of character user interface (CUI) which is console based.
    finalCommand = new String[3];
    finalCommand[0] = "terry :== \"hello\"";
    finalCommand[1] = "sho sym terry";
    finalCommand[2] = s2;
    final Process pr = Runtime.getRuntime().exec(finalCommand);
    2. This represents an executable to which you are passing command line arguments.
    This isn't a java problem because 1 and 2 are not even close to being the same.
    Java won't do anything that you cannot get the application to do itself.
    Your choices:
    1. Find a way to run the app such that it takes commands from a file. You put the commands in a file and pass that to exec()
    2. Find a way that use stdio (the CUI might represent that but there is no guarantee.) You then use exec() to start the app then use the IO streams to pass the commands to it.
    Notice that my choices do not include an option for passing as command line parameters because I am almost certain that it does not exist.

  • Can Reports 3.0 run a host command?

    Can Reports 3.0 run a host command like in Forms 5?
    null

    Hi! Bill
    ANS: NO
    Bill Fox (guest) wrote:
    : Can Reports 3.0 run a host command like in Forms 5?
    null

  • How to run a openssl command from a java program

    Hi All
    Please suggest on how to run a openssl command from a java program.
    I am using this
    Runtime runtime = Runtime.getRuntime();
    runtime.exec("openssl pkcs8 -inform der -nocrypt test.der result.pem");
    This is suppose to take test.der as input and create result.pem.
    There are no errors but the file result.pem isnt created.
    Thanks in Advance

    First off is that openssl command correct? Should it be this instead:
    openssl pkcs8 -inform der -nocrypt -in test.der -out result.pem
    Try out your openssl command within a command prompt so that you know that it works ok. I think the command line you specified waits on stdin (well it does for me).
    After that.....
    runtime.exec creates a Process object. If you do this:
    Process openssl = runtime.exec("....")
    then you can examine the return code from openssl to see the exit code - for instance if the input file does not exist then exit = 1. You can test for this with Java
    Alternatively you could get the stderr from the process and look inside it - if it is 0 length then all is good, if it has some text in there then it has likely failed. You could then throw an exception and include the stderr output in the exception messgae. You may need to experiment with this, runnig it first when openssl is happy then running it again when openssl is upset.
    M

  • How to run multiple DOS commands from a single Webutil Client_Host session?

    Hello all,
    I have a requirement where I need to create an interface with SVN from Forms for basic checkin-checkout of files.
    So, I've been trying to use webutil client_host to open a command line session and issue svn commands.
    For svn, sometimes I need to give multiple commands like change to a particular directory and then run an svn command.
    But client_host takes in only one command at a time and I'm unable to issue a series of DOS commands to perform
    a particular task.
    Is there a way to do this?
    Pls suggest.
    Regards,
    Sam

    First your original question... You can put more than one DOS command on a single line, simply separate each command with an ampersand (&). For example:
    mkdir c:\abc & cd abc & dir*
    Regarding your concerns about performance, well that would depend on exactly what you mean. Using CLIENT_HOST (or HOST on the server) simply opens a shell (DOS in this case) then passes your command to it. The performance of performing this action really isn't measurable. Basically you are just pressing a button and you should get a near immediate action. As for the performance of executing each command, that has nothing to do with Forms. Once the command is passed to the shell, the rest is a function of the shell and whatever command you passed.
    Having said that, if you were to write something sloppy like a loop (in pl/sql) which called CLIENT_HOST lots of times repeatedly, then yes there would be a performance problem because the pushing of the button will cause an exchange to and from the server and each cycle in the loop will do the same.
    So the answer to how performance is impacted will depend on what exactly you need to accomplish. If it is a single call to CLIENT_HOST, this should be fine.

  • Run like Host command in plsql

    Hi,
    We are using Host command in sql*plus , but i need to implement like host command in Plsql. I refered previous post and some other links , that most of them are prefered only java stored procedure, And even that restricted previllage.
    Can you give some sample example launchiing Win OS command in plsql
    venki

    To run a batch file, you need to use the Command Shell (and please do not call it a DOS shell like some people tend to do as it is not DOS). E.g.
    c:\windows\system32\cmd.exe /c c:\temp\test.bat
    We're running cmd.exe with switch /c that tells cmd to execute the command we're passing it, and then to terminate.
    Note that we cannot interact with the shell from the PL/SQL side - we cannot answer prompts and so on. The script run, must be a proper batch/non-interactive script.
    Also, the Oracle Server process (Win32 thread actually) that is servicing our Oracle client connection, is running the command for us. This thread itself is a background service process. It could run in Windows configured environment (VM/Virtual Machine) that is not allowed to interact with the desktop - or have limited or no access to certain files, folders and programs.
    Technically speaking, this is what happens:
    1) we pass the command to execute from our client to the Oracle server session servicing us
    2) this Oracle thread uses the Java VM to make a Win32 call called CreateProcess()
    3) the Win32 kernel executes that process
    4) the process starts, runs and terminates
    5) the Java VM inside the Oracle Server process regains control and pass the exit code and standard output of that process to PL/SQL
    6) PL/SQL in turns, returns that very same data to our client
    If you for example run a program that pauses and expects input, or hangs.. it will cause the above series of steps to stop at step 4. With the Java VM waiting on it to complete, and we waiting for the Java VM and PL/SQL call to complete.

  • Calling SQL Loader using HOST command from Developer Forms 4.5

    I want to execute a set of code from D2K Forms 4.5 which has interfface with Client - OS ( In my case Windows NT/XP). I want to execute SQL Loader from Forms using Host Command and then after completion of that process, I want to do next transcations ( depending upond success of HOST/SQL Loader).
    How to achive this?
    I tried writing code like this ...
    l_vc_command := 'sqlldr73'
                        ||' USERID='||l_vc_username||'/'||l_vc_password||'@'||l_vc_connect_string
                        ||' CONTROL='||l_vc_filepath||'Upload.ctl'
                        ||' DATA='||LTRIM(RTRIM(l_vc_fileloc))
                        ||' LOG='||l_vc_filepath|| l_vc_log_file || '_' || l_dt_sysdate_str ||'.log'                    
                        ||' BAD='||l_vc_filepath|| l_vc_bad_file || '_' || l_dt_sysdate_str ||'.bad'
                        ||' DISCARD='||l_vc_filepath|| l_vc_discard_file || '_' || l_dt_sysdate_str ||'.dsc';
    HOST(l_vc_command,NO_PROMPT);
    After this command i want to do some other code execution. so even if it fails or success, next code is executed. How to control this?
    Please help..
    Regards,
    Milind

    Forms6i running on W2000, Rdbms 8.1.7
    in Forms I added a button TEST,
    Trigger when-button-pressed : host('test.bat') ;
    in directory .......\frm I added file test.bat :
    REM ===============
    cd /d C:\........\ldr
    pause
    sqlldr parfile=test.par
    pause
    type test.log
    pause
    exit
    REM ================
    now, pressing TEST button opens DOS window, telling me what's going on, running sqlldr, finally going back to forms
    Are you using NO_PROMPT or NO_SCREEN option of HOST command ?
    Had a look at Forms 4.5 manuals, there is no mentioning of (a)synchronously operation in connection with HOST command.

  • Host command from sqlplus based on a condition

    I am on an Oracle 10.2.0.3.0 database running on sun solaris.
    Am using my sqlplusw on my windows xp professional to do the below :
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE 10.2.0.3.0 Production
    TNS for Solaris: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    I have 4 variables declared in sqlplus for which I get my values from anonymous pl/sql blocks :
    print db1_status;
    DB1_STATUS
    3
    print db2_status;
    DB2_STATUS
    0
    print db3_status;
    DB3_STATUS
    1
    print db4_status;
    DB4_STATUS
    0
    I needed some help with doing this :
    Based on the values of each these variables, I wanted to invoke the host command to run stuff like
    if db1_status = 3 then
    host ...something
    if db2_status = 0 then
    host ...something
    I am looking for a way to do this without creating an external procedure or java stored programs. Are there any?
    Thanks

    Need to use a batch file (.bat) to utilize SQL Plus while generating the SQL statements within the .bat file.
    Example:
    Inside SQL Plus
    SQL> create table testme (name varchar2(255), value number(5));
    Table created.
    SQL> insert into testme(name, value) values ('db1_status', 3);
    1 row created.
    SQL> insert into testme(name, value) values ('db2_status', 0);
    1 row created.Create a .bat file (Using test.bat)
    test.bat
    @echo off
    echo select value from testme where name = 'db1_status';>temp.sql
    echo exit >> temp.sql
    sqlplus -S %2/%3@%1 @temp.sql > result.dat
    for /f %%x in ('more result.dat') do set RESULT=%%x
    if "%RESULT%" == "3" goto :DB1_STATUS_3
    if not "%RESULT%" == "3" goto :DB1_STATUS_NOT_3
    goto :EOF
    :DB1_STATUS_3
    echo db1_status = 3
    **ENTER SYS COMMANDS HERE**
    goto :EOF
    :DB1_STATUS_NOT_3
    echo db1_status != 3
    **ENTER SYS COMMANDS HERE**
    goto :EOF
    echo select value from testme where name = 'db2_status';>temp.sql
    echo exit >> temp.sql
    sqlplus -S %2/%3@%1 @temp.sql > result.dat
    for /f %%x in ('more result.dat') do set RESULT=%%x
    if "%RESULT%" == "0" goto :DB2_STATUS_0
    if not "%RESULT%" == "0" goto :DB2_STATUS_NOT_0
    goto :EOF
    :DB2_STATUS_0
    echo db2_status = 0
    **ENTER SYS COMMANDS HERE**
    goto :EOF
    :DB2_STATUS_NOT_0
    echo db2_status != 0
    **ENTER SYS COMMANDS HERE**
    goto :EOF
    :EOF
    del temp.sql
    del result.dat
    @echo onAs you can see, this is a simple if/then which takes the value from a dynamically created SQL file (temp.sql) and uses it do determine the next system commands to execute.
    Hope this is what ya needed.
    -Tim

  • Execute a command from servlet

    Hello,
    How can I execute this command from a servlet ?
    example: I want execute "java -cp /root/:/root/log/api/:/root/log/apps/ Transmitter" when I lunch servlet1.java
    so which class in JAVA can do this ?
    Thanks ?

    why u want to run another program? Usually you call the methods within the second program.
    Is it possible to invoke another program in the server using a servlet? If so it could even mess up the whole server. I am not sure.

  • How to simulate HOST command from DB Procedure

    Hi,
    I'm using Oracle 9.2 database on Win2000 PC.
    I need to start .bat file from a database procedure. More generaly how to simulate HOST command that I'm using from Forms6i.
    Thanks,

    Thanks for the reply,
    But, I am able to successffuly execute HOST from SQL+
    only from the PC where the database is, not from the client. My .bat file is on the server side.
    From the procedure I was not able to run it in either cases
    Procedure TEST
    IS
    BEGIN
    EXECUTE IMMEDIATE 'host C:\MYBATCHFILE.BAT'
    END;
    returns ORA-00900 INVALID SQL STATMENT
    with EXECUTE IMMEDIATE '$ C:\MYBATCHFILE.BAT' returns Invalid Character Error.
    BR,

Maybe you are looking for