Calling external applications from within a script.

Whenever I write scripts that require some external application for functionality, I try to open a pipe or start a server so that I only have to start the external application once. I expect that to reduce overhead and consider it good form. However, sometimes there just isn't any way to avoid calling an external application multiple times and when that happens, I try to find some other workaround if I think it's going to get called repeatedly.
What I'm wondering is how much it really matters for very small and simple programs. The one I have in mind right now is "du". I need to use it in a Perl script because Perl's operators to get file sizes return the apparent size which, in this case, is much larger than the actual size reported back by "du". I'm monitoring the size of files in real-time and I need to call "du" during each iteration of the status updater. Even though I'm passing all the file paths at once, "du" may be called a few times every second (well, I could limit it to once a second).
Could this possibly make any noticeable different on older machines? In general, what external apps can you get away with calling repeatedly?

I'm not sure, but I thing that overhead caused by calling du cannot be big enough to matter even on older machines.
But, when calling du from Perl script you are also invoking shell, and this can be a little bit more 'heavy'.

Similar Messages

  • Can you Launch External Applications From Within InDesign Ebook?

    Hi all,
    I was wondering if it is possible to open an external application from within an ebook (created with InDesign) e.g. click on a link and have an external ssh client open up for instance?
    Thanks in advance for any advice.
    Regards,
    RG

    It's possible to include hyperlinks in an InDesign file and export them in an EPUB file. Since I'm not familiar with working with SSH clients (in fact, I just had to Google it to have a clue what you're talking about), is this something that can be invoked in a standard URL format? If so, you could probably include it.
    The next issue is whether the link would work. The link couldn't be used directly in any eBook reader I know of, but at least the iBook on an iPad or iPhone would switch to to Safari to let you follow a URL to its destination. But I don't think that's possible on most eBooks.

  • Calling external programs from within a Tomcat application

    I've got a fairly complex existing Tomcat application (which is packaged and built as a .war file) which I'm trying to edit so that it calls a Perl script part way through the processing, which will generate an XML file used later on. I think I've worked out how to call external scripts from within Java, but at the moment when I try and access the application via Tomcat the application either hangs or bails out (I don't know which, as the log files unhelpfully don't give any error messages).
    The code which is causing the problem looks like this:
    System.err.println("Calling runtime...");
    Runtime runtime = Runtime.getRuntime();
    System.err.println("Executing process...");
    Process process = runtime.exec("/path/to/ysearch.pl 'News' '\"search query\"' 'file");
    System.err.println("Waiting for process...");
    int exitVal = process.waitFor();
    System.out.println("Exited with error code: " + exitVal);The code gets as far as "Executing process..", beyond that there is nothing in the log file so I presume the runtime.exec() call is where the problem is. I'm not interested in reading the output from the script (there shouldn't be any), so that's not an issue, and the permissions on it allow anyone to read or execute ysearch.pl so I don't think there's a problem in that area.
    Does anyone have any suggestions which I could try to get this to work? I've only been using Tomcat for a week (I'm picking up on someone else's code) so I might have made a beginner's mistake. I'm using Tomcat 5 on Fedora Core 7, and Java 1.5.0_01 (I can't easily change any of those).

    I'm not sure, but I thing that overhead caused by calling du cannot be big enough to matter even on older machines.
    But, when calling du from Perl script you are also invoking shell, and this can be a little bit more 'heavy'.

  • Calling External Application from BPM 11g

    I am new to BPM 11g and need to create the ability to call an external application (UCM) from within BPM. Will a web service adapter, with a type of Reference, accomplish this? How can I add security to this web service.
    The second question is how can I add an adapter that alllows me to specify our own source code? In this scenario we would write the Java to formulate the SOAP call directly, thus allowing us to add the security into the call directly.
    Any information is much appreciated.
    Thanks,
    Randy

    Hi Randy,
    You can call an external application using a spring component integration, I was just able to get that to work with a help from another forum member here is a viewlet that demos the spring integration:
    http://bpel.us.oracle.com/BPM/11gR1/howtos/spring-component/oow-2010-Beijing-viewlet/springdemo_v2_viewlet_swf.html
    Alex.

  • To contact 3rd party application from within EJB container

    What are the possible options to communicate with an external application from within EJB container? Options that I can think of are
    - RMI
    - JMS
    - Socket communication
    - HTTP
    - any other option???
    And if anyone can give the pros & cons of the different approaches, based on their experiences it will be great.

    Hi,
    There is one more.
    Web Services which is much powerful than any other.
    Ofcourse for this also u have to use socket communication and http protocol.
    SOAP(Simple Object Access Protocol).. I think u got it..
    I prefer SOAP as it has many adavantages over RMI and other.
    Thanks,
    All the best.
    What are the possible options to communicate with an
    external application from within EJB container?
    Options that I can think of are
    - RMI
    - JMS
    - Socket communication
    - HTTP
    - any other option???
    And if anyone can give the pros & cons of the
    different approaches, based on their experiences it
    will be great.

  • Calling external programs from Java?

    Hi All,
    Is there a way of calling external applications from Java without using Runtime.exec(). That method seems quite messy when you are dealing with streaming data from an input file to an output file. Basically what I'm asking is there a way to run a command the same way you would type it in a command shell?
    Thanks

    LeWalrus wrote:
    Ok, I've an external application that I want to be called inside a Java GUI. It has several input arguements, which the format looks something like:
    programname inputfile > outputfile
    Simple enough.
    >
    Works fine from a shell command line. From what I understand, this won't work using Runtime.exec() because that method will just start the application. Works fine from Runtime.exec(). Since you are'>' to write stdout to a file you need to us a shell to execute the command.
    String[] command = {"sh", "-c","programname inputfile > outputfile"};
    Process process = runtime.exec(command);
    You need to read, digest and implement the recommendations given in http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html .
    File input and output from the application has to be taken care of programatically (java.io stuff). Fine if you've only one input and output. But if you have several input files and hundreds of output files, where does this leave you. It would be much easier if you could pass a string command to the shell directly as if you typed it in the command line yoursel!

  • How to call Operating System commands / external programs from within APEX

    Hi,
    Can someone please suggest how to call Operating Systems commands / external programs from within APEX?
    E.g. say I need to run a SQL script on a particular database. SQL script, database name, userid & password everything is available in a table in Oracle. I want to build a utility in APEX where by when I click a button APEX should run the following
    c:\oracle\bin\sqlplusw.exe userud/password@database @script_name.sql
    Any pointers will be greatly appreciated.
    Thanks & Regards,

    Hi Guys,
    I have reviewed the option of using scheduler and javascript and they do satisfy my requirements PARTIALLY. Any calls to operating system commands through these features will be made on the server where APEX is installed.
    However, here what I am looking at is to call operating systems programs on client machine. For example in my APEX application I have constructed the following strings of commands that needs to be run to execute a change request.
    sqlplusw.exe user/password@database @script1.sql
    sqlplusw.exe user/password@database @script2.sql
    sqlplusw.exe user/password@database @script3.sql
    sqlplusw.exe user/password@database @script4.sql
    What I want is to have a button/link on the APEX screen along with these lines so that when I click that link/button this entire line of command gets executed in the same way it would get executed if I copy and paste this command in the command window of windows.
    Believe me, if I am able to achieve what I intend to do, it is going to save a lot of our DBAs time and effort.
    Any help will be greatly appreciated.
    Thanks & Regards,

  • Calling a webservice from within Bex Web Application Designer

    Hi
    I have a web-template built with BEx web application designer which also contains textboxes. This text should be stored by calling a webservice (standard BI-documents are not an option).
    Can anyone tell me how I could call a webservice from within the BEx web template to store the text contained in the textbox? The webservice-call should include some of the filter-varialbes of the web application.
    Is this only possible by the use of a JavaScript WebItem? If so - does anyone have an example of such a JavaScript.
    Thanks a lot in advance.
    Kind regards.
    Christoph

    Thanks for your response. The BSP page would work out fine if I only needed to save the data.
    But the next time I call the webtemplate, the textarea should be filled by another webservice call with the stored text (so the text can be modified und saved again). This will not be possible by calling a BSP page.
    Do yoiu have any suggestions how to integrate the text (return value from the webservice call) into the textbox in the webtemplate?
    Kind regards.
    Christoph

  • Calling startrfc.exe from within a vbs script

    Hello, can someone help me please
    I am trying to process xml idocs into SAP on a Windows 2008 server. I have written a vbs script to process the file and am trying to call STARTRFC.EXE from within the vbs script. However I keep getting an error that it cannot open the file. The code is shown below. I have changed the server name and gateway and user/passwd for security. I'm passing the filename as a variable (str_expfile) but it does not seem to be able to extract the actual file name from the variable. I know from past experience that you can pass it variables if its running on a unix box and in a shell. But for some reason it not decipering the variable name in the vbs script
    Set objShell = CreateObject("Wscript.Shell")
    str_startrfc = "D:\usr\sap\SID\SYS\exe\uc\NTAMD64\startrfc.exe -d SID -3 -h hostname -s 00 -g hostname -x sapgw00 -u user -p passwd -c 100 -l EN -t -F EDI_DATA_INCOMING -E PORT=MYPORT -E PATHNAME=str_expfile"
    objShell.Run str_startrfc, ,True
    The error I'm getting is shown below:
    ERROR file opened at 20110510 134219 GMT Daylight Time, SAP-REL 700,0,278 RFC-VER 3 1200864 MT-SL
    T:2584 Error in program 'startrfc': ======> Error at OPEN 'str_expfile' (check file)
    T:2584 Error in program 'startrfc': <* RfcReceive [1] : returns 3:RFC_SYS_EXCEPTION
    T:2584 Error in program 'startrfc': <* RfcCallReceive [1] : returns 3:RFC_SYS_EXCEPTION
    Thanks
    Regards
    Steve

    Hi Markus
    Unfortunately I can't do that because I need it to process hundreds of files one after another and I would have to hard code the file path each time. That's why I need it automated.
    Can startrfc.exe not take a variable for the pathname in a vb script? It works fine in a unix shell. We are migrating from unix to windows and I need to convert all my unix scripts into vb scripts.
    I notice there is a nother rfc type program available, can I use rfcexec.exe instead of startrfc.exe and would it take variables?
    Thanks
    Regards
    Steve

  • How to call WebDynpro application from an external application

    Hi All,
    I have an external application, from which an existing webdynpro application should be accessed.
    Is there any way i can access WebDynpro application through an URL, so that i can access the same from the external application.
    I have to pass a parameter also in the url from extrenal application for which that data should be displayed.
    Thanks
    Supriya

    You can call a web dynpro application from an external app by using the web dynpro application url.
    Go to WD application in studio and look at the properties tab, you will find the url.
    It should be something like this:
    http://<host>:<port>/webdynpro/dispatcher/<namespace>/<dc name>/<application name>
    MLS

  • Calling Java application from servlet

    Hi !
    I'm trying to run a Java application from within a servlet with Tomcat 4. I'm using the Runtime.getRuntime ().exec () method. So the application is run in a different JVM as a subprocess of the servlet. I use ObjectInputStream and ObjectOutputStream and a serializable object to enable communication between the servlet and the application.
    I tested the application and the serializable object with another Java application that works as the caller and it works fine. However, replacing the caller application with the servlet I get a StreamCorruptedException. The structure of the caller application and the servlet is the same.
    My questions are:
    - Is there something I should configure in Tomcat to create a subprocess ?
    - What is the cause of the StreamCorruptedException ? How do I get it with the servlet and not with the application ?
    - Should I use an environment with the call to Runtime.getRuntime ().exec () ? How do I use it ?
    - Is the called application forced to run in my servlet's context ?
    - Is there a better way to do this ?
    Thanks to all

    Here's my code:
    1. The serializable object:
    // Object Obj
    import java.io.*;
    public class Obj implements Serializable
    public int n;
    public Obj ()
    n = 0;
    public Obj (int n)
    this.n = n;
    public String toString ()
    return getClass ().getName () + " -> (n = " + n + ")";
    2. The application Sub (subprogram)
    // Application Sub
    import java.io.*;
    public class Sub
    private static File f;
    private static FileWriter fw;
    public static void main (String [] args)
    throws IOException, InterruptedException, ClassNotFoundException
    ObjectInputStream ois;
    ObjectOutputStream oos;
    Obj obj;
    ois = new ObjectInputStream (System.in);
    obj = (Obj) ois.readObject ();
    f = new File ("Sub.txt");
    fw = new FileWriter (f);
    fw.write (obj.toString ());
    fw.close ();
    oos = new ObjectOutputStream (System.out);
    oos.writeObject (obj);
    ois.close ();
    oos.close ();
    3. The application AMain (caller application)
    // Application AMain
    import java.io.*;
    class AMain
    private static File f;
    private static FileWriter fw;
    public static void main (String [] args)
    throws IOException, ClassNotFoundException
    Runtime r;
    Process p;
    ObjectInputStream ois;
    ObjectOutputStream oos;
    Obj obj, obj2;
    r = Runtime.getRuntime ();
    p = r.exec ("java Sub");
    oos = new ObjectOutputStream (p.getOutputStream ());
    obj = new Obj (5);
    oos.writeObject (obj);
    oos.flush ();
    B.comunica (obj);
    System.out.println ("AMain sends to Sub: " + obj.toString ());
    try
    p.waitFor ();
    catch (InterruptedException e)
    System.out.println ("Subprogram was interrupted");
    System.out.println (e.toString ());
    ois = new ObjectInputStream (p.getInputStream ());
    System.out.print ("Sub sends to AMain: ");
    obj2 = (Obj) ois.readObject ();
    System.out.println (" " + obj2.toString ());
    oos.close ();
    ois.close ();
    p.destroy ();
    4. The servlet SMain (the calling servlet)
    // Servlet SMain
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    public class SMain extends HttpServlet
    public void doPost (HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    Runtime r;
    Process p;
    ObjectInputStream ois;
    ObjectOutputStream oos;
    Obj obj, obj2;
    int state, i;
    res.setContentType ("text/html");
    ServletOutputStream out = res.getOutputStream ();
    out.println ("<html>");
    out.println ("<head><title>Sub</title></head>");
    out.println ("<body>");
    out.println ("Invoking subprogram...");
    out.println ("<br>");
    try
    r = Runtime.getRuntime();
    p = r.exec ("java -cp .;c:\\Programs\\Apache~1.0\\webapps\\SMain\\WEB-INF\\classes Sub");
    out.println ("...invoked<br>");
    oos = new ObjectOutputStream (p.getOutputStream ());
    obj = new Obj (5);
    oos.writeObject (obj);
    oos.flush ();
    out.println ("<br>SMain sends to Sub: " + obj.toString () + "<br>");
    try
    p.waitFor ();
    catch (InterruptedException e)
    out.println ("<br>Subprogram was interrupted<br>");
    out.println ("<br>" + e.toString () + "<br>");
    state = p.exitValue ();
    out.println ("<br>Subprogram state: " + state + "<br>");
    ois = new ObjectInputStream (p.getInputStream ());
    out.print ("<br>Sub sends to SMain: ");
    obj2 = (Obj) ois.readObject ();
    p.destroy ();
    catch (SecurityException e)
    out.println ("<br>SecurityException<br>");
    out.println ("<br>" + e.toString () + "<br>");
    catch (IOException e)
    out.println ("<br>IOException<br>");
    out.println ("<br>" + e.toString () + "<br>");
    catch (Exception e)
    out.println ("<br>Exception<br>");
    out.println ("<br>" + e.toString () + "<br>");
    out.println ("</body>");
    out.println ("</html>");
    So, as you can see, both application AMain and servlet SMain invoke application Sub and pass it the serializable object Obj. Oddly enough, application AMain works fine whereas servlet SMain throws a StreamCorruptedException exception.
    johnpoole said:
    �It's hard to guess what would cause the exception without seeing code, but the interaction between the processes would differ from that between two applications, because the servlet process is started with a different class loader. I'm not sure which one the jvm started by the call would use.�
    How can I enforce that a System classloader be used in the call to Runtime.getRuntime ().exec () ? (I mean by System classloader a classloader equals to the one applications are launched from console).
    johnpoole said
    �Is there a reason why you aren't starting the second process manually and then connecting to it on a port?�
    The idea is providing a Web interface for an application running in the server. The servlet is used to restrict access to this application but once access is granted (passing the servlet) the application should not be constrained.

  • Calling Java Application from another

    How can i call a Java Application from another java App.
    eg., If my Java application is called MyApp and i would like call another java application from within it.
    One way could be by using "System". I would like to know if there is any other method and is portable.
    Thanks in advance.

    hi,
    it works and not!
    if you start an other class with a command like this the 2nd prog/class terminates too if you terminate the caller-class!
    dear
    oliver scorp

  • Calling report application from jsp

    Hi,
    I am designing a JSP that captures search parameters. The user will enter words contained in a company name and product codes. This triggers the jsp to display all matches on the same page. My question is how do I call a portal report application from within the jsp and pass the parameters? Also, I would like to change the column condition relational operator for the date parameters.
    Thanks for any help,
    Ed

    Hi,
              I found that when i changed the permissions on the following directory to 777 the error in weblogic went away.
              /local/apps/boxir2/boinstall/bobje/data/<domainname>.pageserver
              However i still have the web page error when i try to load a crystal reports document that is:
              An error occurred while creating a Page Server subprocess.
              Any help with this would be great.
              Thanks

  • Using 'export -f FUNCTION' from within a script doesn't work

    Why doesn't the 'export -f FUNCTION' work as expected in the following:
    #!/bin/bash
    target="$1"
    [[ -z "$target" ]] && echo "No target specified." && exit 1
    work() {
    bsdtar -xOf "$target" .PKGINFO | egrep -w 'pkgname|arch|pkgdesc|group|conflict|depend|replaces' | sed -e 's/pkgname/\npkgname/' >> /scratch/pkgs.log
    export -f work
    find /scratch/repo -name "$target*.pkg.tar.xz" | parallel work
    It errors out when called:
    % ~/bin/repo/check_pkgs broadcom
    zsh:1: command not found: do_work
    zsh:1: command not found: do_work
    zsh:1: command not found: do_work
    zsh:1: command not found: do_work
    zsh:1: command not found: do_work
    zsh:1: command not found: do_work
    zsh:1: command not found: do_work
    zsh:1: command not found: do_work
    zsh:1: command not found: do_work
    zsh:1: command not found: do_work
    zsh:1: command not found: do_work

    moetunes wrote:The command you are exporting is called work. The command it fails on is do_work
    That was a copy/paste error based on me trying multiple scripts.  Sorry about the confusion.
    % ./test linux
    zsh:1: command not found: work
    zsh:1: command not found: work
    falconindy wrote:
    It's also the wrong solution to be exporting functions...
    Yay for ineffective crossposting... https://bbs.archlinux.org/viewtopic.php?id=153461
    Exporting functions is recommended in the parallel man page.
    The command must be an executable, a script, a composed command, or a function. If it is a function you need to export -f the function first. An alias will, however, not work (see why http://www.perlmonks.org/index.pl?node_id=484296).
    Also, how is this a cross post?  The post you referenced is about parsing input, this one is about calling a function from within the parent script.
    Awebb wrote:Why does zsh report a problem with a bash script?
    No idea
    Last edited by graysky (2012-11-24 14:35:15)

  • Calling a report from unix shell script

    Hi,
    I had to call a report from unix shell script.
    May i know the procedure to accomplish this
    Thanks in Advance
    A.Gopal

    First you should not include the whole path to your report in the call ...
    Use like this:
    /ora/u01/oracle/v101/as2/bin/rwrun.sh report=an_stati destype=file desname=/ora/u01/oracle/v101/as2/test.pdf desformat=pdf
    In $ORACLE_HOME/bin/reports.sh:
    1) Verify that you have updated the REPORTS_PATH variable to include your folder where you have the report in question
    REPORTS_PATH=/ora/u20/app/qits/env1/run:$ORACLE_HOME/reports/templates:$ORACLE_HOME/reports/samples/demo: ....
    2) Verify that the REPORTS_TMP variable is pointing to a valid location and that the oracle user has access to write on it.
    After that, post the content of the tracefile located at $ORACLE_HOME/reports/logs/{in-process report server name folder}/rwserver.trc
    If no file is present then it means that you need to enable trace in your reports's conf file.... go to the $ORACLE_HOME/reports/conf folder and and locate the .conf file that correspond to your in-process reports server name (as specified in the rwservelet.properties file)... open/edit the file to enable trace logs ..
    i.e.
    Change the following line:
    <!--trace traceOpts="trace_all"/-->
    to <trace traceOpts="trace_all"/>
    Bounce the reports server and try to run the report again, this time the .trc file should be generated, post the content so that we can take a look.

Maybe you are looking for