Execute a shell or perl script

Is it possible to execute a unix(solaris) shell script or perl script from a stored procedure. If so, a short example would be great.
Thanks,
John

External Procedure Source Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void sh(char *);
void sh( char *cmd )
int num;
num = system(cmd);
Issue the following commands to compile the code and generate the shared
object in Solaris:
cc -G -c shell.c
ld -r -o shell.so shell.o
You can also use the demo_rdbms.mk makefile to build shared libraries for use in external procedures. Using this method insulates you from any Operating System specific dependencies (e.g., which flags to use
for ld).
For example:
In 8.0.X,
$ make -f demo_rdbms.mk extproc_nocallback \
SHARED_LIBNAME=shell.so OBJS=shell.o
In 8.1.X,
$ make -f demo_rdbms.mk extproc_no_context \
SHARED_LIBNAME=shell.so OBJS=shell.o
Library Definition
CREATE LIBRARY shell_lib is '/u11/home/lsupport/proc/shell.so';
Note: The directory in quotes is the current of location of the library that
was created in the steps above.
PL/SQL Wrapper Procedure
create or replace procedure shell(cmd IN char)
as external
name "sh"
library shell_lib
language C
parameters (cmd string);
Execution
SQL> exec shell('ls');
cli.trc exe_prba.sql prueba.mk shell.c.old
core listener.old prueba.o shell.o
dec2bin.c listener.ora prueba.so shell.so
dec2bin.c.old nena.lst prueba.sql shell.sql
dec2bin.o p.sql sal.1 shell.sql.old
dec2bin.so pepito.lst sal.2 sqlnet.log
dec2bin.sql prb sal.3 tnsnames.ora
dec2bin.sql.old prb.c salida.lst tnsnames.ora.old
envoltorio.sql prueba.c shell.c uno.sql
PL/SQL procedure successfully completed.

Similar Messages

  • Shell or perl script from OS command_Sender File Channel

    Hi All,
    I am trying to execute a perl script from the File Sender Channel(NFS), OS command Before Message Processing. The script works fine if i run it from the shell. But when PI calls the script,  the script does not get executed. The audit logs mention that the OS command has been called.
    I tried using:
    1) /<fullpath>perlScript.pl /<fullpath>filename.dat
    2) perl /<fullpath>perlScript.pl /<fullpath>filename.dat
    Both these commands work fine when i execute them on the shell.
    I am on solaris and PI 7.0. The permission for the perl script and input files are all 777.
    FYI.. i am using this perl script to transpose a complex file and make it # delimited file.
    I have already read the blogs for OS command and executed some sample scenarios successfully.
    I tried to call a shell script that does the same functionality as the perl script. Even that does not work.
    Also, wrote a shell script to call the perl script inside it. No luck.
    eg:
    touch /fullpath>/create_before.dat
    perl /<fullpath>perlScript.pl /<fullpath>filename.dat
    touch /<fullpath>/create_after.dat
    In this case, the create_before.dat and create_after.dat is getting created but the perl is not called. I know this because i cant see the output files of the perl script.
    Regards,
    Balaji
    Edited by: Balaji M on Oct 30, 2008 2:36 PM

    Hi,
    The problem is fixed. The shell or perl both have logic to transpose a non industry starndard file to the delimited file which PI can use an FCC to pick up.
    This was the fix:
    we need to mention the shell the script is going to be run in.
    In the shell script we mentioned --> *#!/usr/bin/bash* as the first line
    normally, when we use the command -- which bash on the unix command prompt, it tells us the path for the bash used.
    another option --> #!/usr/bin/ksh
    again, on the command prompt -- which ksh command will tell us what ksh is being used.
    If the script is a simple one that does copy or move commands, i believe we need not use the commands above. But is a good practice to have them in the script.
    Regards,
    Balaji
    Edited by: Balaji M on Nov 3, 2008 4:38 PM

  • How to disable "This Connection is Untrusted" warning in firefox using shell or perl script running on Linux Platform

    We have QA automation jobs that invoke user interface tests in Firefox running on a virtual Linux host.
    My tests perform regression, but I'm held up because of the Firefox This Connection is Untrusted warning.
    My current requirement is to ignore this connection untrusted warning, which comes up when accessing an HTTPS website and i want this to be disabled through either a shell or a Perl script.
    I can do this manually using the steps below, but this will not work for my current problem since the virtual Linux hosts are created dynamically on submission of automation jobs.
    Go to Tools > Options > Advanced "Tab"(?) > Encryption Tab Click the "Validation" button, and uncheck the checkbox for checking validity.
    Is there any Perl or shell script that disables this certificate warning?

    There might be an add on to accomplish this:
    *[https://addons.mozilla.org/en-US/firefox/addon/skip-cert-error/ Skip Cert Error]
    However if we cannot find a solution there might be another place for support:
    *[https://support.mozilla.org/en-US/kb/where-go-developer-support Where to go for developer support]

  • Urgent Problem in Executing perl script from shell script

    Hello,
    I've a shell script on one server (source) and a perl script on another (target).
    My perl script will check whether the directoryname, filename provided by shell script exists on the target server or not.
    My shell script is as follows:
    #! bin/bash
    cmd=`ssh user@target "perl /home/user/test_dir/validate_file.pl"`
    echo $cmd
    And my perl script uses a package CU_Functions.pm, which is in the same directory as the perl script on the target server.
    But when I invoke the perl script from shell script, I get the following error:
    Source:user> (db:ias10g12_mid_db) /home/user/perl
    $ sh /home/user/arcs/arcs_conn.sh
    user@target's password:
    Can't locate CU_Functions.pm in @INC (@INC contains: /local/perl-5.6.1/lib/5.6.1/i686-linux /local/perl-5.6.1/lib/5.6.1 /local/perl-5.6.1/lib/site_perl/5.6.1/i686-linux /local/perl-5.6.1/lib/site_perl/5.6.1 /local/perl-5.6.1/lib/site_perl .) at /home/user/test_dir/validate_file.pl line 13.
    BEGIN failed--compilation aborted at /home/user/test_dir/validate_file.pl line 13.
    Please let me know if I need to do any configurations prior to call the perl script.

    As for the Perl INC, I cannot recall the environment variable that sets that but the following example should work:
    ssh user@host "export ENV_VAR=/path/to/include/files:$ENV_VAR ; /full/path/to/script"

  • How to execute unix shell script from Java ...

    Hi,
    Anyone know how to execute unix shell script from Java?
    Suppose I have several shell scripts written in perl or tcl or bash.
    I just want to catch the output of that script.
    Is there any ready to use module/object for this?
    Please let me know, this is quite urgent for my study assigment.
    Thanks in advance,
    Regards,
    me

    Look up Runtime.exec()

  • Execute Perl Script from Forms

    Ji all, is there a way to execute a Perl Script out of Forms beside WEB.SHOW_DOCUMENT ?

    Depends on where the script should be executed. If its on the application-server and you can wrap it into a shell-script, then you can also use HOST.

  • Can servlets/ jsp automatically run perl scripts and executables?

    I'm a student and am new to to servlets and web programming in general.
    I need to know if it's possible to run perl scripts and executables automatically from servlets/ jsp.
    The program I am planning on creating should have a client outside a firewall that uploads perl files to a gateway machine inside the firewall, the servlet should be able to run this perl file, and then pass the resulting file as an argument to an executable, to be run by another servlet on a different server.
    I've tried looking everwhere for an answer to this and am about to revert to a cgi based approach because I'm not sure if it would work so any help/ suggestions would be much appreciated.

    Hallo,
    I think using java Runtime will help. you can do Processes that execute shell or system commands through
    Process process = Runtime.getRuntime().exec("your perl scripts here!");
    Bye

  • Executing a shell script from a java program

    Hi,
    I'm facing a problem while executing a shell script from a jsp page.
    I'm using exec() function.
    It's working fine for single statement scripts.But if the script consists of any database processing and some other processing statements,it's not returning the correct exit status of the process.
    Will u please help me in this.
    If there is any other ways to execute a shell script from a jsp page other than Runtime.exec().If so let me know.
    Thanks in advance.

    I think this shud workMaybe - but it is wrong! Why do you create aReader
    and then read bytes which are turned into a String
    without worrying about whether or not the bytes area
    String and without worrying about the character
    encoding if the bytes do represent characters and
    without worrying about how many bytes wereactually
    read.
    Also, both you and the OP should read, digest and
    follow the advice given in
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-
    traps.htmlI dont care if it is wrong. This code works for me.
    We are here to solve problems not to find which post
    is wrong.It is wrong! You are posting bad advice that is very wrong! It may work for you but it is wrong in general! WRONG WRONG WRONG.
    If you have a solution then post it I did post a solution! The reference I gave will explain to you and the OP exactly how it should be done.
    rather then
    posting rude comments.I was not rude! I was explaining just some of what was wrong!

  • Executing a shell script from a jsp page

    Hi,
    I'm facing a problem while executing a shell script from a jsp page.
    I'm using Runtime.exec() function.
    It's working fine for single statement scripts.But if the script consists of any database processing and some other processing statements,it's not returning the correct exit status of the process.
    Will u please help me in this.
    If there is any other ways to execute a shell script from a jsp page other than Runtime.exec() like RMI etc,.If so let me know.
    Thanks in advance.

    Hello,
    It's hard to help you but what you can do is listening to the outputs of your script, you should read the output stream and error stream and send them to the default console.
    Check this excellent article : http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=4
    Best regards,
    Olivier.

  • Error while executing unix shell script from java program

    Hi All,
    I am trying to execute unix shell script from a java program using Runtime.execute() method by passing script name and additional arguments.
    Code snippet :
    Java Class :
    try{
         String fileName ="test.ksh";
         String argValue ="satish"; // value passed to the script
         String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
         Process proc = Runtime.getRuntime().exec(exeParam);
         int exitValue = proc.waitFor();
         sop("Exit Value  is : "+exitValue);
    catch(Exception e)
    e.printStackTrace();
    }Test.ksh
      export -- application realated paths..
      nohup  abc.exe 1> test.log 2>&1;
      $1
      exit.By running the above java class , i am getting exit Value: 139 and log file test.log of 0 bytes.
    when i am running the same command (/usr/bin/ksh test.ksh satish) manually, it's calling abc.exe file successfully
    and able generate the logs properly.
    Pls let us know where exactly i am stuck..
    Thanks in advance,
    Regards,
    Satish

    Hi Sabre,
    As per the guidelines provided by the article, i had done below changes..
    InputStream is = null;
    InputStreamReader iStreamReader = null;
    BufferedReader bReader = null;
    String line = null;
    try{
    String fileName ="test.ksh";
    String argValue ="satish"; // value passed to the script
    String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
    Process proc = Runtime.getRuntime().exec(exeParam);
    is = proc.getErrorStream();
    iStreamReader = new InputStreamReader(is);
    bReader = new BufferedReader(iStreamReader);
    System.out.println("<ERROR>");
    while((line = bReader.readLine()) != null)
    System.out.println("Error is : "+line);
    System.out.println("</ERROR>");
    int exitValue = proc.waitFor();
    sop("Exit Value is : "+exitValue);
    catch(Exception e)
    e.printStackTrace();
    Now , it's showing something like..
    <ERROR>
    </ERROR>

  • How to execute unix shell script in webdynpro?

    hi all,
      We have some iquirement of executing script in unix.If anyone know How to execute unix shell script in webdynpro?
    best regard
    reefish

    Ree,
    1. Find SSH client for windows, then execute SSH with Runtime.exec() on local host with arguments like remote host, auth, command to execute etc.
    2. Get SSH client in Java and execute SSH commands on remote host using pure Java API.
    Don't ask me for links, Google works today, I checked this
    Valery Silaev
    SaM Solutions
    http://www.sam-solutions.net

  • Execute perl script from CPO

                       Hi everyone,
    Is it possible to execute a perl script directly from CPO without using a cgi or soap action, If yes, is there any documentation or model workflows that I can refer to...

    Its a prewritten script hosted in a linux box(svc cat server), first we tried to invoke it as a soap request...
    <?xml version="1.0" encoding="UTF-8"?>
    http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
    ">
    #username#
    this worked but we want to discontinue this approach,
    so we tried to host the script as cgi and invoke the cgi directly...
    but this is not working, so wanted to see if we can execute the script from CPO either directly by using CLI or by hosting the script in a server

  • How to execute a shell script?

    Hi,
    could someone please tell me the correct way to execute a shell script? For example run.sh located in my resources?
    Thanx in advance!

    Odds are good that Apple doesn't want you running shell scripts on an iPhone, but somebody else might have information to the contrary.

  • How can I get firefox to execute perl scripts from local files

    I have created perl scripts on my local host (file type ".pl").
    In MS Windows I have associated that type to a perl interpreter installed on my local host.
    IE allows me to create links to them and to execute them (after asking for permission).
    How can I get firefox to do the same? It doesn't seem to allow me to add application types, only to change those that are already defined. As a result, in firefox, they just show up as text, instead of being executed.

    First guess is that you did not use an .html extension on the file. The file may well be ''name.html.txt''
    * see http://www.bbc.co.uk/webwise/guides/file-extensions
    *http://windows.microsoft.com/en-gb/windows/show-hide-file-name-extensions#show-hide-file-name-extensions=windows-vista
    Forum Note
    This is normally offtopic for this forum. I say normally because now we cover webmaker questions. I wonder if this is therefore on topic as a webmaker question?
    I have tagged with webmaker-contribution

  • Execute perl-script using java

    Hi All
    I would like to execute a perl script (inside a java app) and retrieve its output. This java program needs this output.
    Can someone give me information on how to do this ?
    Thanks a lot in advance
    Luca

    Ok, solved it:
    import java.lang.Runtime ;
    import java.io.* ;
    public class Test {
         public static void main ( String ARGV[] ) {
              Runtime r = Runtime.getRuntime() ;
              Process p = null ;
              DataInputStream dis = null ;
              String s ;
              try {
                   String cmd[] = new String[1] ;
                   cmd[0] = "./a.pl" ;
                   p = r.exec(cmd) ;
              dis = new DataInputStream(p.getInputStream());     // create file I/O
                   s = dis.readLine();     
                   System.out.println("|"+s+"|") ;
                   s = dis.readLine();     
                   System.out.println("|"+s+"|") ;
              catch(IOException e) {}
    }

Maybe you are looking for

  • How To Delete a User Folder from the Catalog?

    When logged into the Catalog Manager as the Administrator I am not allowed to delete individual user folders, even when the user has been deleted via the 'Manage Presentation Catalog Groups and Users' link in the front end. If the Administrator user

  • PDF dimensions problem

    Hi I have a problem when i create a PDF file from a .png picture. The dimensions changes for some reason. I've made the background transparent. I'm using Xara Xtreme Pro 5 for the design. When i create a picture and export it as a .png file, it holds

  • App Designer/Compare Reports

    Anyone? Could someone please give some guidance on how they typically run Compare Reports either in App Designer or through Change Assistant? We were recently upgraded from 8.9 to 9.2 and I've newly assumed the role of administering our PeopleSoft sy

  • Why does my iMac keep crashing?

    Please help.  3rd time today while in the middle of working on an .ai file. Here is the crash report: Anonymous UUID:       5F6560A8-F694-1502-F82D-E8E014E68C1C Tue Jun 24 15:39:25 2014 panic(cpu 0 caller 0xffffff80204c5490): "Possible memory corrupt

  • When updating Flash Player

    I get regular updates for Flash Player. After updating usually within minutes, a hijack attempt is made to reroute my browser through Beyond the Network America. I am sure these attempts occur only after updating Flash. Here is my hypothesis: I routi