Call Unix Script from JSP.

Hi,
I need to run a unix script from a JSP page.
JSP pages reside on a different machine.
How can i call the unix script resides on different machine from JSP.
Thanks,
Narendra

yah. I can access that machine telnet and having all credentials of that system.
Can you please share the code needed for this.
Thanks,
Narendra

Similar Messages

  • Problem when call unix script from jsp

    Dear all,
    I want to list all the file in a unix directory and display in jsp.
    And the directory have below files:
    -tmp1.txt
    -tmp2.txt
    -log.txt
    -blog.txt
    I used the runtime object and Runtime.exec ('ls -lrt') which can get the file list suceesful.
    But when i use Runtime.exec('ls -lrt tmp*) , then it get nothing.
    Pls kindly help.
    Tks

    I agree with DrClap. But you may need to do "shell wild-card expansions" for something else. Your type of question is asked quite frequently in the forums. Do a little more research. As a hint. Java will not expand your "tmp*". A Unix shell will however. So you need to pass your little command to a Unix shell and have java execute the shell command along with your "ls -lrt tmp*".

  • Calling UNix Script from portal Form

    Has anyone conquered this issue through jav or plsql. I need to call a unix script from the portal form when I select the insert button.

    I have several very convoluted ways which all work, but I have always thought there should be more straightfwd ways. Fundamentally the easiest way to call something from the Insert button is to add some PL/SQL code before (or after) the "doInsert();" call in the Insert Button event handler.
    What seems to be lacking is the ability to get from pl/sql to the o/s. So until we know how to do that you have to call a method in Java to execute o/s commands - specifically you can use Runtime.getRuntime().exec(cmd); where Runtime is a class in java.lang, and cmd is the actual o/s command (script or whatever).
    How to call this Java is then where you have several options:
    1. Compile this piece of Java into the Oracle DB as a SP.
    2. Deploy this piece of Java within a Java servlet on a 9iAS instance. Then have another SP call this servlet using the utl_http package (begin_request and other sp's within package).
    Which options would depend on several factors including your preference but most importantly whether you have a DB or a 9iAS instance on the machine where you want to execute the script. If you have neither you have a problem. In such cases I have used a standalone OC4J container which has a very small footprint.
    As I said these methods are all quite convoluted and if anyone else has anything better I would like to know (but they work quite reliably).
    Cheers.
    Anton.

  • Calling Unix-Script from within Oracle and store stdout/stderr in table

    Hi,
    What I want to do is:
    1. Calling a UNIX script (e.g. hello.sh) (from inside the Database)
    hello.sh
    echo “Hello World!“
    2. and get the stdout/stderr output back in my Database in a table (e.g. temp_back)
    table temp_back
    ID     stdout          stderr
    1     Hello World!
    I think Number 1 isn’t a big problem, but how to get stdout back in DB?
    Any solution?
    I searched a bit in this Forum and found this Post.
    re:Calling Host Command Through Database  Procedures or Triggers
    This may be what I am searching for, but can’t access the Link
    Since I am not really fit with UNIX and packages/procedures in Oracle it would be nice if you could post a very detailed answer.
    (Please no java)
    -What packages do I need? (heard DBMS_OUTPUT would be useful)
    -example PL/SQL script
    Thanks a lot!
    Marcus
    Environment:
    Oracle 9.2.0 DB

    Marcus, if you opened the Java sandbox to access any o/s file, you can call any Unix command, shell script, or program, that the Oracle o/s user has exec privs on.
    Just remember that there's a very basic Unix environment when you make the call - the settings in the .profile does not apply. Thus PATH for example is not set. When making the call make sure that the complete path is given. As for the environment, that is a problem as you cannot set that and make the call at the same time.
    In that case it is much simpler to rather write a Unix shell script that does all for you. Set the environment. Run the command(s). Format output. Etc.
    Then you call that Unix script, via Java, from SQL or PL/SQL. Treat the Unix scripts like the Unix-version of stored procedures for your Oracle application.
    Some technical details. When you connect to Oracle, a Unix process services you. This can be either a dedicated server process (servicing only your Oracle session) or a shared server process (from the shared service pool of processes).
    In either case, it is a Unix process running as a background process (thus detached from any tty device). PL/SQL and SQL are executed by this process. The Oracle JVM created by your session also lives in this process. When you therefore make o/s calls, these calls are made by this process.
    Therefore you are limited to what this process can and can't do. E.g. it runs as the oracle o/s user and will fail on accessing paths and commands does the oracle user does not have privs on. Etc.

  • Call a unix script from pl/sql package

    Hi,
    Using 11.2.0.3 on AIX.
    Is it possible to call unix script from pl/sql package?
    I am cretaing a file in a directory but would like this to automatically be written to an archive directory as well.
    Could either use 2 utl_file.put_lines to 2 separate directories or 1 utl_file and cal script to archive file in another directory.?
    Thoughts?
    Thanks

    user5716448 wrote:
    What am I doing wrong?think how file name will look like:
    SQL> select 'file_name' || to_char(sysdate,'DD/MM/YYYY HH24:MI:SS') from dual;
    'FILE_NAME'||TO_CHAR(SYSDATE
    file_name15/08/2012 11:47:51Will AIX swallow such name? Obviously not. And, unfortunately, UTL_FILE.FCOPY doesn't raise an error in such case. So use someting like:
    UTL_FILE.FCOPY ('SOURCE_DIR',v_FILE_NAME,'DEST_DIR',v_file_name||to_char(sysdate,'DD_MM_YYYY_HH24_MI_SS'));SY.

  • Call a unix script from ABAP program

    Can anybody help me on how to call a unix script from an ABAP program
    Regards
    Anjali

    Hi try the below code
    parameters : p_sfile(60) lower case
              "File to be moved
              "Eg : /home/in/SFILE1.txt
                p_dfile(60) lower case.
              "File's Destination
              "Eg: /home/archive/SFILE1.txt
    data : t_btcxpm
           like btcxpm occurs 0,
           p_addparam
           like sxpgcolist-parameters.
      concatenate
      '/home/ABAP/scripts/Archive_file.sh'
      p_sfile
      p_dfile
      into p_addparam separated by space.
      refresh t_btcxpm. clear t_btcxpm.
      call function 'SXPG_CALL_SYSTEM'
        exporting
          commandname = 'ZSHELL'
          additional_parameters = p_addparam
        tables
          exec_protocol = t_btcxpm
        exceptions
          no_permission              = 1
          command_not_found          = 2
          parameters_too_long        = 3
          security_risk              = 4
          wrong_check_call_interface = 5
          program_start_error        = 6
          program_termination_error  = 7
          x_error                    = 8
          parameter_expected         = 9
          too_many_parameters        = 10
          illegal_command            = 11
          others                     = 12.
      if sy-subrc = 0.
        write : /
        'File',p_sfile,'moved to',p_dfile.
      else.
        write : / 'Error Occured'.
      endif.

  • Call a Perl Script from JSP

    Hi guys,
    I am developing an online ticket booking system.
    i have come toa point where i need to call a perl script from JSP.
    please let me know how to do it.
    Basically, i need to call a function in perl script from JSP in order to encrypt my information.
    Any help is appreciated.
    Thanks in advance.
    Chintan Shah

    I haven't done this myself, but it seems like it is possible in Tomcat.
    You can configure Tomcat to handle .cgi calls (it does this via a CGI servlet)
    http://www.ftponline.com/javapro/2003_03/online/perl_teden_03_18_03/
    http://tomcat.apache.org/tomcat-5.0-doc/cgi-howto.html
    Once this is set up, theoretically you should be able to then use requestdispatcher and forward/include a cgi script to invoke the perl.
    I don't know if you are using Tomcat or not though... :-)

  • Executing Unix scripts from a stored procedure

    From the sql*plus windows, I am able to execute the host command and '!sh' commands; but I need to ececute Unix scripts from a stored procedure. Hoe can I do this? Where can I get good documentation on this? Any help would be greatly appreciated!
    Thanks..

    Hi,
    U can use external procedure ( newly added feature in 8.0.3 onwards) and call any shared library. From shared library u can execute it.
    One sql command is there HOST(' '). U can run a OS command. But u can not use it in PL/SQL.
    U can call pls sql from shell !!!!!..
    Thanks...
    Boby Jose

  • How to call unix script/command in ODI

    Hello Gurus,
    Please let me know how to call unix script/command in ODI?
    Thanks
    Shridhar

    you can call shell script using the OS command found in Package.
    Step 1. Drag the OS Command in the Packgae
    Step 2. In the Text mentiond call the script say for ex sh /opt/path/script.sh
    Step 3. Execute.
    Note : Make sure the User through which ODI is triggering does have the required permission to execute shellscript , also always provide the full path , since scripts are execute from the oracldi/bin folder so its necessary to provide the complete path of the script location.
    Hope this helps.

  • Problem executing Unix script from Java...

    Hi there, I'm having trouble executing a unix script from a java program. The script receives multiple parameters and it seems that one of them ( or more ) is not well interpreted. When I run the script directly from a shell, the script executes without any errors. But, when I run the exact same script with the exact same parameters, it does not work.
    Here is the command to execute the script with all the parameters that is executed from the shell ( with success ) and also from the java program ( with errors ):
    /z/opus/dcap/intfu001.csh 'NODEBUG^NOTKPROF^NOSTACK' opus dcap JACQUES JACQUES '2625781' 'ORA$PIPE$001D00D70001' JOB^DEBUG^SINISIMU^STATPROD^DECTIDANC^81^503^4080^86^87^151^97^98^99 BUT^N^N^SPRI^0^13^24^3^J^05^N^19^19^19 >> /tmp/switcher8.999.null.pgm.test
    And here is my portion of code that executes the script:
    Runtime wShell = Runtime.getRuntime();
    Process wProc = wShell.exec(cmd_unix_final);
    wProc.waitFor();
    return wProc.exitValue();
    Please give me your thoughts on this!
    Thanks in advance!

    Ok.
    Let's proceed surgically, else we'll never solve or overcome anything.
    In the last your reply you wrote:
    the normal output is what I get when the script runs successfully, the script first prints a few things
    and then does stuff that takes at least 2 or 3 secondsWhat do you mean?
    -Finally have you got your script correctly executed?
    The stuffs you spoke of are really performed?
    If this is the case I can't see the prob.
    Is your concern only about exitValue() for it doesn't let you distinguish programmatically
    the success or failure of the script execution?
    Of course you surely already have a routine in your java code to handle
    exceptional situations of errors from the script.
    And the "normal output" is just what you must parse to detect those errors.
    Then who cares about exitValue() in this case?
    Don't invoke it, relay on the stdout and stderr of the script.
    -Or you get only a deceiving standard output
    that let you think the script execution went alright, while instead it didn't.
    In this case we have to investigate some other thing.
    I can't still exclude that the problem isn't related with the buffer size of the stdout
    allocated by the environment to the subprocess. You spoke of few things printed out.
    Be explicit. What's the size of the output you get?
    And is the "normal output" complete till the very last char
    or is it truncated from somewhere on?
    Also it's important that you hit a ps command after the java main process terminates
    (or simply when waitFor() returns) and see if the script subprocess hung up.
    As an alternative approach directly call your pro*C code from Java through JNI, instead of translating it.
    1. Exec.java
    public class Exec{
         static{
              System.loadLibrary("Exec");
         public static native void proCFunct();
         public static void main( String[] args){
              proCFunct();
    }2. javac Exec.java
    3. javah Exec
    4.Exec.c
    #include "Exec.h"
    JNIEXPORT void JNICALL Java_Exec_proCFunct(JNIEnv * a, jclass b){
         //here call the function that executes the script
    5. cc -G -I$JAVA_HOME/include -I$JAVA_HOME/include/solaris -I$YOUR_INCLUDES Exec.c -o libExec.so
    6. setenv LD_LIBRARY_PATH .
    7. java Exec

  • How to run a Unix Script from a specific user

    Hi,
    I want to run a GoldenGate related unix script from a super user. I have created crontab enter from that super user. But its still running from root user. As GGSCI cannot be invoked other than super user, the Script is failing.
    The Script is running fine on command prompt and from "at" batch job command.
    Please give me a way to run the script from a specific user on Cron
    Thanks,
    Saravana

    Hi.
    can you show:
    grep root /etc/passwd
    grep <super user> /etc/passwd (It's not clear for me, what you call super user. For me - root is super user. )
    ls -la /var/spool/cron/crontabs
    Generaly for add cronjobs for any user need:
    crontab -e <username>
    For more information - man crontab
    Reagrds.

  • Calling a script from rman

    Hi Experts,
    Is it possible to call a script from rman.
    database 9i
    Recovery catalog 10g.
    Ex :
    connect target test/test@TEST;
    connect catalog rman/rman@RMAN
    @backup (where backup is a datafile backup script on unix)
    I dont know if there is any other way of calling a script within an rman script.
    Any ideas....
    Thanks in Advance
    MB

    OK,
    I understood. The file .SQL is for SQL statements only, not for RMAN commands.
    You can create a shell script on Unix named your_backup.sh on /home/oracle directory,
    for example.
    This shell script file (bellow) is with your rman code, like this:
    #!/bin/sh
    # Name: A name for the shell script
    # Author: You
    # Description: Executes backup for Sunday using the RMAN
    # Updates:
    export ORACLE_HOME=$1
    export ORACLE_SID=$2
    export LOG_DIR=$3
    # Variables:
    SCRIPT="your_backup"
    data_log=`date '+%y-%m-%d_%H:%M:%S'`
    logfile=${LOG_DIR}/${SCRIPT}-${data_log}.log
    # Execution of script backup of rman:
    $ORACLE_HOME/bin/rman <<EOF > $logfile
    connect target rman/rman
    connect catalog rman/rman
    run{
    set controlfile autobackup format for device type disk to '%F';
    allocate channel d1 type disk format '/tmp/SID/df_s%s_p%p_t%t';
    restore controlfile to '/PATH/ctl/cntrlTEMP.dbf' from autobackup;
    replicate controlfile from '/PATH/ctl/cntrlTEMP.dbf';
    sql "alter database mount";
    release channel d1;
    EOF
    exitto you execute this script, you can do this on the unix:
    [oracle@server oracle]$ /home/oracle/your_backup.sh /u01/app/oracle/product/9.2.0.1.0 devdb /home/oracleThis script is going to generate log file to you analyze.
    []´s

  • Calling unix script using oracle forms

    we have to call unix script using oracle forms , a trigger in form calls stored procedure on database
    that stored procedure on database calls a oracle shared library
    but since the only listener account for oracle on our unix server is oralist , whenever a call is made to the unix script from the oracle form , the unix script is executed by oralist user
    but issue that we are having now is since oralist is specific for listening connections from orale we dont want to use this user to establish SFTP on it to avoid any issues with oralist
    we want the sftp to be established on soem other useraccount , so is it possible to do something so that the script is executed by an account other that oralist.

    I'm not a Linux/Unix specialist, but I think this may work: let your database call a shell script that does a su command before running the actual script:
    su - other_account
    your_script.sh

  • Call PERL script from JAVA

    I am facing a problem in running a PERL script in JAVA in UNIX box..
    I am able to call ther perlscript.
    Perl script has
    #! /usr/local/bin/perl
    print "\nEnter Your Name :";
    $name = <>;
    print "\nYour Name is : $name\n";
    exit 0;
    Perl script request for the INPUT(name) .
    My Java program is
    File perlfile = new File("test.pl");
    Runtime runtime = Runtime.getRuntime();
    Process process = runtime.exec("perl "+perlfile);
    Here is the problem tat IT IS says error =2 ..What has to be the solution so tat i can CALL PERL SCRIPT as similiar to running it separatly in prompt { >perl test.pl }
    PLEASE help me on this....

    In the PERL SCRIPT (test.pl)
    LINE 1 : #! /usr/local/bin/perl
    LINE 2 : print "\nEnter Your Name :"; .
    LINE 3 : $name = <>;
    LINE 4 : print "\nYour Name is : $name\n";
    LINE 5 : exit 0;
    When i run this script in perl test.pl in prompt (UNIX BOX), i am gettin the request for name "Enter Your Name:____ " but when i call this script from Java it doesn't request for name and moreover the process doesnt ends (use ctrl+c to come out of the process).When i come out forcefully it shows the ERROR=2.
    My requirement is such tat need to call a PERL SCRIPT from java so tat java process give the control to PERL script and it will continue the process..
    Sample scenario:
    Java move a file and store it in a new FOLDER
    MY perl script will read the file in new FOLDER.
    here the perl script will get the file name for processing... My issue comes here .$name is not be prompted while calling thro java..

  • How can i run unix script from my apex page

    how can i run unix script from my apex page and take the output of unix script as a hidden variable and display it on the report region of that page

    I had a requirement to run a Fortran program against some data that woudl be extracted from the database after the user set up their filtering criteria and made some additional input. SInce the program was to complex to conver to PL/SQL, we decided to try and invoke it from Apex. This is how I did it.
    1. I followed the steps in Tim Archer's excellent article "Oracle External Procedure to Run Host Commands" (http://www.timarcher.com/?q=node/9). If the link does nto work, google the article's title.
    Using this steps I created a function which accepts any OS command, including calling my own shell scripts, and runs them. I called my PL/SQL function "shell" instead of "USF_RUN_HOST_CMD " as Tim did in his example (step 9).
    2. In Apex,
    a. I created a button to run my shell command. (I named it P2_RUN_SHELL)
    b. I created a PL/SQL process whose source looks as follows:
    shell('/home/ackness/scripts/cr_xcf_file.sh > /tmp/cr_scfp_file.log');
    and which was conditioned on the the button P2_RUN_SHELL.
    It works like a charm.
    Note: since you can run your own scripts using this method, you can encapsulate a series of commands in a UNIX shell script and invoke that script from Apex. This allows you to be able to test or run you commands from the command line as well as Apex and makes it easier to develop/debug/enhance the scripts in the future.
    Ackness

Maybe you are looking for

  • Please Help me : I Didn't set any password for my back up and now it's locked what should i do ?

    Hi , i just restored my iPhone and now that i wanna restore my backup (contacts) it's locked i didnt put any password when i was backing up , any idea ?

  • Balance different  in  S_ALR_87012993 due to over settle

    User encounter a problem during run an order report using T-code S_ALR_87012993. The balances for the IO in this report suppose is Zero balance, but the report come out with a balance of RMB 12,846.91.  When I drill into order actual line item (i.e.

  • Importing CRM On Demand Environment Certificates on SOA Suite.

    Hi All, I am trying to invoke CRM On Demand Environment Web Services from a SOA Suite. Normally for CRM On Demand Environment you will need to import a Certificate as it is an external Environment hosted by Oracle. I am able to do add the certificate

  • AP Isolation feature

    I have a linksys Wrt150N. I was reading the manual for Advanced wireless settings and i came across AP isolation which said "wireless devices will be able to communicate with the Router but not each other". I have three computers(2 wireless and 1 dir

  • Problem with logic at-selection screen

    Hi ,     I have this piece of code : I have 3 radiobuttons and corresponding screens and fields like r_matnr s_charge etc on that screen . default radio button is r_build . a) If on this screen is user forgots to give value for s_matnr then error is