Trying to use grep from within java,using exec command!

Hi all!
I would like to run a grep function on some status file, and get a particular line from it, and then pipe this line to another file.
Then perfom a grep on the new file to check how many of the lines above are present in that file, and then write this value to a new file.
The final file with a numerical value in it, i will read from within java,as one reads normal files!
I can run simple commands using exec, but am kinda stuck with regards to the above!
Maybe i should just do all the above from a script file and then run the script file from exec. However, i dont want to do that, because it kinda makes the system dependent,..what if i move to a new machine, and forget to install the script, then my program wont work!
Any advise?
Thanks
Regards

With a little creativity, you can actually do all that from the command line with a single command. It'll look a little crazy, but it can be done.
Whether the script exists on the local machine or not has zero to do with platform indpendence. You assumedly have to get the application onto the local machine, so including the script is not really an issue at all. However, you're talking about system independence, yet still wishing to run command line arguments? The two are mutually exclusive.

Similar Messages

  • Running ssh from within java program

    Hi!
    I am trying to start ssh from within java e.g.:
    Runtime run = Runtime.getRuntime();
    Process pro = run.exec("ssh -l xx 12.12.12.12");
    But it complains:
    socket: Operation not permitted
    ssh: connect to host 12.12.12.12 port 22: Operation not permitted
    Running ssh from the command prompt works just fine. It's run on win xp.
    What is the problem, and how can I avoid it?
    Endre

    Afraid not. I think maybe it's related to security permissions, but I am really not sure. If you can help, I would appreciate it.
    - Endre

  • Re-use message mapping from within java mapping?

    Hi there,                                                                               
    I have a question regarding java mapping. What I would like to do is to re-use an existing message mapping from within java mapping.
    Technicaly, message mapping is perfomed by com.sap.aii.mappingtool.tf3.AMappingProgram.execute, right? I would like to call that mapping program for a specifc message mapping from within my java mapping.
    Pseudo java code would look like this:
    public void execute(InputStream in, OutputStream out)
      throws StreamTransformationException {
    com.sap.aii.mappingtool.tf3.AMappingProgram.execute(in,out,'SomeMessageMapping');
    SomeMessageMapping is a message mapping that is defined in the integration repository.
    Is it possible? If so, could you provide me with some details?
    Thank you and best regards,
    Wolfgang

    Hi Wolfgang,
    very interesting idea?
    I would activa a dummy message mapping. than I would have a look in the file directory of the java-stack and try to find out the name of the *.class or *.jar file.
    On the other hand you could generate a tpz-transport-file an unpack this file, to explore the name of the *.class or *.jar
    Unfortunately I do not have access to the file system. So I can't explore the name.
    Regards Mario

  • I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    Logged the call with SAP who directed me to 'Define settings for attachments' in IMG and setting the 'Deactivate Java Applet' & 'Deactivate Attachment versioning' checkboxes - problem solved.

  • Using APEX_MAIL from within a procedure invoked from DBMS_JOB

    I have done a lot of googling and wasted a couple of days getting nowhere and would appreciate some help. But I do know that in order to use APEX_MAIL from within a DBMS_JOB that I should
    "In order to call the APEX_MAIL package from outside the context of an Application Express application, you must call apex_util.set_security_group_id as in the following example:
    for c1 in (
    select workspace_id
    from apex_applications
    where application_id = p_app_id )
    loop
    apex_util.set_security_group_id(p_security_group_id =>
    c1.workspace_id);
    end loop;
    I have created a procedure that includes the above (look towards the end)
    create or replace procedure VACANCIES_MAILOUT
    (p_application_nbr number,
    p_page_nbr number,
    p_sender varchar2)
    AS
    Purpose: Email all people registerd in MAILMAN [email protected]
    with details of any new vacancies that started listing today.
    Exception
    when no_data_found
    then null;
    when others then raise;
    l_body CLOB;
    l_body_html CLOB;
    l_vacancy_desc VARCHAR2(350);
    to_headline varchar2(200);
    to_org varchar2(100);
    l_vacancies_desc varchar2(2000);
    to_workspace_id number(22);
    CURSOR vacancies_data IS
    select DISTINCT v.headline to_headline,
    ou.org_name to_org
    from VACANCIES v,
    Org_UNITS ou
    where
    ou.org_numb = v.Org_Numb
    and v.public_email_sent_date is Null
    Order by ou.org_name, v.headline;
    BEGIN
    BEGIN
    FOR vacancies_rec in vacancies_data
    -- build a list of vacancies
    loop
    BEGIN
    l_vacancy_desc := '<br><b>' ||
    vacancies_rec.to_org || '<br>' ||
    vacancies_rec.to_headline || '</b><br>';
    -- l_vacancy_desc :=
    -- vacancies_rec.to_org || ' - ' ||
    -- vacancies_rec.to_headline ;
    l_vacancies_desc := l_vacancies_desc || l_vacancy_desc;
    END;
    END LOOP;
    END;
    l_body := 'To view the content of this message, please use an HTML enabled mail client.'||utl_tcp.crlf;
    l_body_html :=
    '<html>
    <head>
    <style type="text/css">
    body{font-family:  Verdana, Arial, sans-serif;
                                   font-size:11pt;
                                   margin:30px;
                                   background-color:white;}
    span.sig{font-style:italic;
    font-weight:bold;
    color:#811919;}
    </style>
    </head>
    <body>'||utl_tcp.crlf;
    l_body_html := l_body_html || l_vacancies_desc
    || '<p>-----------------------------------------------------------------------------------------------------------------</strong></p>'
    ||utl_tcp.crlf
    || '<p>The above new vacancies have been posted on the <strong>Jobs At Murdoch</strong> website.</p>'
    ||utl_tcp.crlf
    ||'<p>For futher information about these vacancies, please select the following link</p>'
    ||utl_tcp.crlf
    ||'<p> Jobs At Murdoch </p>'
    ||utl_tcp.crlf
    ||'<p></p>'
    ||utl_tcp.crlf;
    l_body_html := l_body_html
    ||' Regards
    '||utl_tcp.crlf
    ||' <span class="sig">Office of Human Resources</span>
    '||utl_tcp.crlf;
    for c1 in (
    select workspace_id
    from apex_applications
    where application_id = 1901)
    loop
    apex_util.set_security_group_id(p_security_group_id => c1.workspace_id);
    end loop;
    apex_mail.send(
    p_to => '[email protected]',
    p_from => '[email protected]',
    p_body => l_body,
    p_body_html => l_body_html,
    p_subj => 'Jobs At Murdoch - new vacancy(s) listed');
    update VACANCIES
    set public_email_sent_date = trunc(sysdate,'DDD')
    where public_email_sent_date is null;
    commit;
    END;
    but still get the error
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    ORACLE_HOME = /oracle
    System name: Linux
    Node name: node
    Release: 2.6.18-194.17.1.el5
    Version: #1 SMP Mon Sep 20 07:12:06 EDT 2010
    Machine: x86_64
    Instance name: instance1
    Redo thread mounted by this instance: 1
    Oracle process number: 25
    Unix process pid: 5092, image: (J000)
    *** 2011-07-12 09:45:03.637
    *** SESSION ID:(125.50849) 2011-07-12 09:45:03.637
    *** CLIENT ID:() 2011-07-12 09:45:03.637
    *** SERVICE NAME:(SYS$USERS) 2011-07-12 09:45:03.637
    *** MODULE NAME:() 2011-07-12 09:45:03.637
    *** ACTION NAME:() 2011-07-12 09:45:03.637
    ORA-12012: error on auto execute of job 19039
    ORA-20001: This procedure must be invoked from within an application session.
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 290
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 325
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 367
    ORA-06512: at "HRSMENU_TEST.VACANCIES_MAILOUT", line 94
    ORA-06512: at line 1
    Can someone please tell me what what stupid thing I am doing wrong? The procedure worked when invokded from SQL Workshop but fails in a DBMS_JOB.
    much thanks Peter

    I think that might help...
    http://www.easyapex.com/index.php?p=502
    Thanks to EasyApex..
    LK

  • I am trying to stream music from my iMac using iTunes music files to my Cocktail Audio X10 music streamer. I have allowed my files to be shared the X10 sees the files but when I try to accsess them it gives me the message files not mounted. Please help?

    I am trying to stream music from my iMac using iTunes music files to my Cocktail Audio X10 music streamer. I have allowed my files to be shared the X10 sees the files but when I try to accsess them it gives me the message files not mounted. Please help?

    No, I have the music I want to move from the laptop to the phone selected. Then I go under file, devices, and try to click sync but it is not available to click.

  • Cross-component: Call method of using component from within used component?

    Hi,
    I began diving into cross-component programming.
    Meanwhile after having digged into some scenarios some questions came up to my mind that I am not able to answer myself. I would appreciate your help here!
    Say we have to components.  Comp A uses Comp B (hence, B is a component usage in A)
    1) How to make them communicate not on a data level (via context binding) but on a process level, thus...
    a) can I call A's method from within B? How is the approach on a general level? - as B can be used from totally different components (like A, A1, A2 ...)
    b) perhaps the only way to do this is by firing events? If so, how can I react in A when an event in B (marked as interface event) gets fired? As it seems they do not get registered within A directly...
    I guess the question seems to be a bit tricky. Nevertheless, I think there will be plenty of you out there who used to asked them the same questions before and came up with an approach. Would be nice to hear from you.
    Best wishes,
    Marc @sap1

    Hi,
    thanks for your reply!
    Indeed, I think the nature of WDA would be just to somehow map the context from the used component to the other back and forth.
    Nevertheless, what if I would like to invoke a method of the using component from inside the used component.
    One sample for this requirement could be e.g.:
    Component B offers a tree item and a send/verify button.
    Component A uses B and has some restraints regarding what the selection should look like.
    The user taps the button in B (at runtime in the view container of A), the context gets updated in A and B and in Component A the verifyWithOwnConstraints() method gets called (through B).
    Thanks again,
    Marc

  • Is there any way to use Quickview from within Spotlight search results?

    I'm sure this has been answered previously, but my searches came up empty....
    Is there any way to use Quickview from within Spotlight search results? I'd like to be able to do a Spotlight search and hit the space bar for a quick Quickview look before actually launching the program. I'm guessing this isn't possible, but thought I'd ask...

    Thanks, Kappy.
    Duh...I meant Quick Look. Sorry about that.
    In any event, pressing the space bar in Spotlight just puts a space in the Spotlight search box - it doesn't open a Quick view of the highlighted item...

  • How to get the Weblogic Server Id from within java code

    I would like to log which server (among a cluster) a certain job is running on. Is there a way to get the server id from within Java code (this code is in a session bean if that is relevant.)
    By server id I mean the "Name" column in the summary of servers on the weblogic console.
    Thanks,
    ken

    Use the two entries close to the bottom of the page: "list WebLogic
    MBeans:listMBeans.jsp
    display MBean attributes and operations:showMBean.jsp"
    Nils
    Anatoly wrote:
    >
    Cameron,
    That page has these items on it:
    which one do you think helps with my issue?
    Misc WebLogic examples
    LongRunningTask
    Execute tasks in parallel using WebLogic Execute Threads
    Weblogic stats (5.1)
    Reload Servlet(s) programmatically (5.1)
    Network classload from WebLogic:using reflection,or the launcher
    Weblogic 5.1 debugging properties
    Seppuku pattern readme
    Using dynamic proxies to intercept EJB invocations (6.1)
    list WebLogic MBeans:listMBeans.jsp
    display MBean attributes and operations:showMBean
    Thanks to Marcelo Caldas for filter by type option and nice UI!
    Using com.sun.jdmk.comm.HtmlAdaptorServer with WebLogic 6.1
    Cool
    EJBGen
    Dimitri
    back
    "Cameron Purdy" <[email protected]> wrote in message news:<3c7a745d$[email protected]>...
    JMX ... see http://dima.dhs.org/misc/ for some info on JMX in Weblogic.
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Clustering Weblogic? You're either using Coherence, or you should be!
    Download a Tangosol Coherence eval today at http://www.tangosol.com/
    "Anatoly" <[email protected]> wrote in message
    news:[email protected]..
    Does anyone know who to get the managing server URL's port
    from within the EJB code running on Weblogic 6.1?
    The URL port is not default (not 7001), but when creating
    initial context, I am not specifying the URL in properties.
    Due to that, trying to the the PROVIDER_URL property from
    environment does not return anything.
    Appreciate any responses.
    -Anatoly
    ============================
    [email protected]

  • I can take video made in Photo Booth and use in my Smilebox greetings and I can use photos from iPhoto to use there also.  I have not been able to figure out how to take clips from iMovie for that.

    For anyone who has used "Smilebox" for greeting cards:  I can take video made in Photo Booth and use in my Smilebox greetings and I can use photos from iPhoto to use there also.  I have not been able to figure out how to take clips from iMovie for use with Smilebox.

    For anyone who has used "Smilebox" for greeting cards:  I can take video made in Photo Booth and use in my Smilebox greetings and I can use photos from iPhoto to use there also.  I have not been able to figure out how to take clips from iMovie for use with Smilebox.

  • IPhone 6plus camera freezes when trying to take photos from within other apps

    Hi,  8.1 6Plus,   my regular camera turns black screen when trying to take photos from within other apps or sometimes between photos in the regular camera app.  I can still take a photo, I just have no idea what I'm seeing or taking a picture of.   Then when I press retake (in other apps) the screen comes back on and it works.   Its annoying more than anything else.   Any ideas? Have done the whole close apps/restart process.
    Thanks!

    What version of iPhoto? How much disk space did you have before deleting things?
    Regards
    TD

  • Executing vbscript from within java

    Hi,
    Does anyone knows a way to execute a vbscript from within java and capture its output.
    thanks

    Do you mean emulate an interpreter?

  • Executing a perl script from within java application

    Hi,
    Does anyone knows a way to execute a perl script from within java.
    ---kirk

    Runtime.exec("perl myscript.pl");
    Of course whether that "works" depends on what the script does and where the java program runs.

  • Problems trying to retrieve data from R/3 using Java - RecordSetWrapper

    Hello everyone!
    I am having problems retrieveing a result from r/3 using Connector Framework API. An ABAP consultant has created a ABAP program which returns an employee based on his or her personal number as an input.
    <b>When i run the AbstractPortalComponent i get the following:
    <u>RS2: com.sapportals.connectors.SAPCFConnector.execution.structures.RecordSetWrapper@24648563</u></b>
    My code is as follows:
    package com.sap.test;
    import java.util.ArrayList;
    import java.util.Iterator;
    import javax.resource.cci.MappedRecord;
    import javax.resource.cci.RecordFactory;
    import com.sap.security.api.IUser;
    import com.sapportals.connector.connection.IConnection;
    import com.sapportals.connector.execution.functions.IInteraction;
    import com.sapportals.connector.execution.functions.IInteractionSpec;
    import com.sapportals.connector.execution.structures.IRecordSet;
    import com.sapportals.connector.execution.structures.IStructureFactory;
    import com.sapportals.connector.metadata.functions.IFunction;
    import com.sapportals.portal.ivs.cg.ConnectionProperties;
    import com.sapportals.portal.ivs.cg.IConnectorGatewayService;
    import com.sapportals.portal.ivs.cg.IConnectorService;
    import com.sapportals.portal.prt.component.*;
    import com.sapportals.portal.prt.runtime.PortalRuntime;
    public class Search extends AbstractPortalComponent{
         String sapSystem = "*****";
         public void doContent(IPortalComponentRequest request, IPortalComponentResponse response){
              IConnection con = null;
              ConnectionProperties conprop = null;
              ConnectionProperties cp = null;
              try{
                   Object connectorService = PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);
                   IConnectorGatewayService cgService = (IConnectorGatewayService) connectorService;
                   cp = new ConnectionProperties(request.getLocale(),request.getUser());
                   if(cgService == null){
                        response.write("Error in getting Connector Gateway Service <br>");
                   try{
                        con = cgService.getConnection(sapSystem, cp);
                        IInteraction ix = con.createInteractionEx();
                        IInteractionSpec ixSpec = ix.getInteractionSpec();
                        ixSpec.setPropertyValue("Name", "Test_RFC");
                        RecordFactory rf = ix.getRecordFactory();
                        MappedRecord importParams = rf.createMappedRecord("INPUT");
                        IFunction function = con.getFunctionsMetaData().getFunction("Test_RFC");
                        IStructureFactory structureFactory = ix.retrieveStructureFactory();
                        IRecordSet table = (IRecordSet) structureFactory.getStructure(function.getParameter("I_PA0002").getStructure());
                        importParams.put("PERNR", "123456");
                        MappedRecord output = (MappedRecord) ix.execute(ixSpec,importParams);
                        Object rs = null;
                        try{
                             Object result = output.get("I_PA0002");
                             if(result == null){
                                  rs = new String ("Error");
                                  response.write("RS1: " +rs+ "<BR>");
                             else
                                  if(result instanceof IRecordSet){
                                       rs = (IRecordSet) result;
                                       response.write("RS2: " +rs+ "<BR>");
                                  else{
                                       response.write("RS3: " +rs+ "<BR>");
                        catch(Exception e){
                             response.write("Error " + e.getMessage()+ "<BR>");
                   catch(Exception e){
                        response.write("Connection to SAP system failed <br>");
                   if(con == null){
                        response.write("Connection is null <br>");
                   else{
                        response.write("Connection succsesful<BR>");
              catch(Exception e){
                   response.write("Exception occured<BR>");
              try{
                   con.close();
                   response.write("Connection closed<br>");
              catch(Exception e){
                   response.write("Could NOT close connection<BR>");
    The result should be all data stored on the person which I search for, but instead i get the following result:
    <b>
    RS2: com.sapportals.connectors.SAPCFConnector.execution.structures.RecordSetWrapper@24648563</b>
    I am really stuck and do not know how to solve the problem. I appreciate any help or sample (or just some answers...)
    Thanks in Advance.
    Best Regards,
    Ola Aarthun

    Hi,
    From your code you are just displaying the object rs. You have to handle the display of each record the way you want it(as a table).
    You can find a sample code how to build a table from the result object at the following link
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/bfb1ba90-0201-0010-5e97-bd6a8f5022dc
    Regards,
    Padmaja

  • Can I use SimpleFdkCredential() from within a servlet?

    I have a test program that logs in to content DB using SimpleFdkCredential, and works perfectly well run from the main() method of a Java class from within JDeveloper. When I try to login the same way from within the doGet() method of a servlet, doGet() hangs on the call to ManagersFactory.login() using the same SimpleFdkCredential that works in-process. The login() call doesn't throw any exceptions, it just sits there waiting[I presume], and never returns.
    Is it necessary to use S2SFdkCredential for any authentication that originates from a servlet invocation? It seems that SimpleFdkCredential should work in this instance as well.
    Thanks.

    Can you check the Content DB http node log (application.log) with debug log level set, to see if the request from the servlet for the RemoteLoginManager Web Service was received?
    I would also check that all libraries are present/accessible from servlet - and that there are no conflicts with existing libraries.
    Also, check the servlet log for anything strange.
    Finally, you could try remote debugging of your servlet .. e.g -Xdebug java option.
    -Matt.

Maybe you are looking for