Getting the Output Stream of  a Process without exec()ing it first.

Hi there,
I am writing a java application which needs to open another application "gnuplot". Now my operating system is windows and I open pgnuplot .
Also I want to send input to the above gnuplot (say plot sin(x) ) via the outputStream. The following is what I do :-
     String gnuplot_cmd = "plot sin(x)\n" ;
          Process p = Runtime.getRuntime().exec("C:/gnuplot/gnuplot4/bin/pgnuplot.exe");
          PrintWriter gp = new PrintWriter(p.getOutputStream());
          gp.print(gnuplot_cmd);
          gp.close();
But the above doesn't work fully , in that only the blank wgnuplot terminal window pops up however I am unable to direct input to the gnuplot application.
The reason being that , pgnuplot checks for
its stdin being redirected the moment it's started. If, at that time,
the "PrintWriter" is not yet connected to the OutputStream of the
process, that check will fail, and pgnuplot will revert to just executing
wgnuplot, without any command line redirection.
I am facing a problem of how to attach a OutputStream to the process, without getting exec()ing the process.
Is there anyway at all, i can get a process without starting it, so that I can attach an output Stream to it before it gets executed?
I am open to work arounds, anything that will automate the process of writing to the gnuplot terminal.
thanks!
nandita.

The reason being that , pgnuplot checks for
its stdin being redirected the moment it's started.
If, at that time,
the "PrintWriter" is not yet connected to the
OutputStream of the
process, that check will fail, and pgnuplot will
revert to just executing
wgnuplot, without any command line redirection. I'm not convinced this analysis is correct. gnuplot doesn't need to know that there's a PrintWriter there, and it probably can't know. It just needs to know whether its standard input is coming from console or not. The Java library code that can invoke processes probably handles the redirect right away, and that's why there's the OutputStream available even before you create the PrintWriter.
exec can be tricky. I think the problem may be that you're not dealing with standard output or standard error. Read this:
When Runtime Exec Won't
If that still doesn't help, there may be options to gnuplot to tell it exactly where its input is coming from.

Similar Messages

  • Are You All Able to get the Output In EXCEL Format

    Hi All,
    I have one question. Are You All Able to get the Output In EXCEL Format?? I am working on Oracle Apllication 11.5.10.2 and my XML builder is 5.0.1. Problem which i m facing is this...... Whenever i am submitting a concurrent program with format type different from PDF i could not able to view the ouput in desired format. When i am pressing view output it gives me a file in XML and when i save that file with extention 'xls' or 'rtf' then i could able to see the saved file in desired format.
    Can anyone tell me where is the problem??? Is it a bug?
    I am using microsoft world 2000 sp-3.
    Please give your valuable comments. May be your comments can solve my problem..
    Thanks
    Ravi

    Hi I got Same issue
    When I change Format to EXCEL from
    Submit request>> Option>> Format = EXCEL
    In window I am getting something HTML code and
    when I try to copy it to Browser from Tools>> Copy File in to Browser I am getting following message
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    End tag 'p' does not match the start tag 'a'. Error processing resource 'http://our url.com:8000/OA_CGI...
    <p class="c0"><a name="Text4" id="Text4"><a name="Text1_1" id="Text1_1"><span class="c1">Dept No <...
    But I can see the output when Format is PDF
    Pls suggest solution ,I am using EBS 11.5.10.2.
    Thanks
    Rahul
    Message was edited by: Rahul
    user576181

  • How to get the output of a C prgram to Java to the parent Java program

    Hi,
    Suppose there is a Java Program which calls inside it the C program.The C program outputs as below
    printf("%c%c",c1,c2);
    Now I have to take this output as an input of the Java Program for further processing.How can I do this?
    Tapas

    By reading from the output stream of the C program.
    (if you're not already reading the output stream of the program anyway, you should be - http://java.sun.com/developer/JDCTechTips/2005/tt0727.html#2 )
    The format is a char, a space, a char, so just call read() three times and ignore the second value.

  • How to get the output format options of SAP QUERY

    Hi Gurus,
    I want to get the output options available for sapquery program.means when you execute the program "AQZZ/SAPQUERY/FDF1============" you will get output options like sap alv,display as table,wordprocessing  etc.
    i am not able to unsderstand the logic in that standard code.my requirement is after fetching the data from the database i want to provide the ouput options SAP ALV,DISPLAY AS TABLE,WORD PROCESSING,SPREAD SHEET,FILESTORE.
    I can output the data in SAP ALV and i can store the data.But i am not able to use the the remaining options in my program.please provide me solution.
    I am very much thankful to the people who can provide me the solution.

    Hi,
    If you have a query then go to transaction 'SQ01' . Then press the change button . Then u will able to see the Output Options.Their u can select the option what ever u want.

  • Getting the output from a Perl script using Runtime.exec

    I cannot get the output from a perl script using Java. Can someone PLEASE help?
    I used the following code:
    Process p = Runtime.getRuntime().exec("C:\\Perl\\bin\\Perl.exe script.pl) ;
    InputSream in = p.getInputStream();
    b...
    do
    System.out.println(b);
    while ((b = in.read()) > 0)
    But there is no way that I get the output in the inputstream. If I use the command "cmd script.pl", the output is displayed in the Dos box, but also not in the inputstream.
    I will appreciate any help.

    Try this
    Process p = Runtime.getRuntime().exec("C:\\Perl\\bin\\Perl.exe script.pl) ;
    BufferedReader rd = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String str;
    while((str=rd.readLine())!=null){
    System.out.println(str);
    Manu

  • Error flushing the output stream in Sun One server

    Hi All,
    I was running my servlet code in iPlanet 6.0 version and it was working fine. I upgraded my web server to new Sun One server (Oracle-iPlanet-Web-Server-7.0.9). With the new web server almost 90% of my application works fine, but there is a features in my application to download an Excel sheet by clicking a button. This feature is failing in new Sun One web server.
    Below are my piece of code and the error log I m getting. Can anyone tell me how I can fix this error, I mean is there any web server specific change or configuration parameter need to be set.
    Please ask for any information regarding my server configuration settings if needed for finding a solution for this
    Code:
    byte abyte0[] = new byte[1024];
    BufferedInputStream bufferedinputstream=null;
    BufferedOutputStream bufferedoutputstream=null;
    java.io.InputStream inputstream = httpurlconnection.getInputStream();
    bufferedinputstream = new BufferedInputStream(inputstream);
    bufferedoutputstream = new BufferedOutputStream(httpservletresponse.getOutputStream());
    int j;
    long byteCount=0;
    while((j = bufferedinputstream.read(abyte0, 0, 1024)) != -1)
    byteCount=byteCount+j;
    if(logger != null && logger.traceOn())
    logger.log("total"+byteCount);
    logger.log("Read bytes:"+j);
    bufferedoutputstream.write(abyte0, 0, j);
    if(logger != null && logger.traceOn())
    logger.log("Wrote bytes:"+j);
    bufferedoutputstream.flush(); // <<<<<< ERROR POINT >>>>>>
    Error Log :
    ClientAbortException: java.io.IOException: WEB8004: Error flushing the output stream
    at org.apache.coyote.tomcat5.OutputBuffer.doFlush(OutputBuffer.java:343)
    at org.apache.coyote.tomcat5.OutputBuffer.flush(OutputBuffer.java:313)
    at org.apache.coyote.tomcat5.CoyoteOutputStream.flush(CoyoteOutputStream.java:147)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:124)
    at com.reuters.bdec.as.ASRequestHandler.processResponse(ASRequestHandler.java:285)
    at com.reuters.bdec.as.ASRequestHandler.initiateGetRequest(ASRequestHandler.java:89)
    at com.reuters.bdec.as.ASRequestHandler.proceedToDestination(ASRequestHandler.java:220)
    at com.reuters.bdec.as.ASExtension.authorisationCheck(ASExtension.java:84)
    at com.reuters.bdec.as.ASExtension.doGet(ASExtension.java:114)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:794)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:915)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:398)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:255)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:586)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:556)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:586)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:556)
    at com.sun.webserver.connector.nsapi.NSAPIProcessor.service(NSAPIProcessor.java:160)
    Caused by: java.io.IOException: WEB8004: Error flushing the output stream
    at com.sun.webserver.connector.nsapi.NSAPIProcessor.action(NSAPIProcessor.java:243)
    at org.apache.coyote.Response.action(Response.java:197)
    at org.apache.coyote.tomcat5.OutputBuffer.doFlush(OutputBuffer.java:339)
    ... 20 more

    Don't flush it yourself. The servlet container will automatically flush for you once its send buffer is full. You can change the size of the send buffer though.

  • How to get the output .pdf file of a quiz to report to the quiz results analyzer on my internal server (mamp)

    I created a quiz.
    Created an internal server on my compute rising a MAMP.
    When I publish my quiz using the multi-file publishing options...
    I am able to use both the "HTML" and the "swf" output files to complete a quiz and reporting the results to the quiz results analyzer.
    However, I am unable to get the output .pdf field to reporting to the quiz results analyzer.
    Any help? Would this issue have to do with the Acrobat Professional setting? Captivate setting? My internal server setting? or output fuel placement?
    I tired to put the .pdf file in the same MAMP root folder location as my "internalserverreporting.php and internalserverread.php files.
    Thanks for the help.

    Hello Varun,
    You cqan submit the report as a JOB and export the out put to memory, once the job is complete you can read the list to display the output.
    Cheers,
    Mano
    Cut & Paste form SAP help.
    Submit report ....
    EXPORTING LIST TO MEMORY
    Does not display the output list of the called report, but saves it in ABAP memory and leaves the called report immediately. Since the calling program can read the list from memory and process it further, you need to use the addition ... AND RETURN . Also, since the called report cannot be requested for printing, the addition ... TO SAP-SPOOL is not allowed here. In addition, you must not assign a function code to the ENTER key in the current GUI status. The saved list is read from the SAP memory using the function module 'LIST_FROM_MEMORY' and can then be saved to the database using EXPORT, for example. You can process this list further with the function modules 'WRITE_LIST', 'DISPLAY_LIST' ... of the function group "SLST".

  • Row should be locked before getting an output stream from an attribute

    I have table Worker with photo attribute (its database type is ORDSYS.ORDIMAGE, entity attribute type is OrdImageDomain).
    I use standard display and edit renderer for displaying and changing ord-image attribute.
    If I add new worker and set him photo, everything is OK.
    But if I edit some existing worker and set them photo, while posting to database exception is thrown.
    This problem began some time ago, after made some changes (like upgrade JDev, changing some AM configuration properties, and so on...), but I ca't reproduce right behaviour.
    I use JDeveloper 9.0.3.2, database is Oracle8i Release 8.1.6.0.0, I tried reserved and stateful AM mode both (the same bad result), pesimistic locking.
    Error occures inside Tomcat 4.1.27 and OC4J both.
    Does anybody know any hint about this error...?
    Than you very much
    Jan
    PS. Error message datail:
    oracle.jbo.DMLException: JBO-26041: Failed to post data to database during "Update": SQL Statement "JBO-25040: Row should be locked before getting an output stream from an attribute.".
         at oracle.jbo.server.EntityImpl.doDMLWithLOBs(EntityImpl.java:4542)
         at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:4422)
         at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:3544)
         at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:2290)
         at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:2232)
         at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:1527)
         at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:1693)
         at oracle.jbo.html.jsp.datatags.CommitTag.doStartTag(CommitTag.java:45)
    ## Detail 0 ##
    oracle.jbo.JboException: JBO-25040: Row should be locked before getting an output stream from an attribute.
         at oracle.jbo.domain.BaseLobDomain.getOutputStream(BaseLobDomain.java:729)
         at oracle.ord.im.OrdDomainUtil.loadAndSetProperties(OrdDomainUtil.java:656)
         at oracle.ord.im.OrdImageDomain.saveToDatabase(OrdImageDomain.java:2325)
         at oracle.jbo.server.EntityImpl.doDMLWithLOBs(EntityImpl.java:4521)
         at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:4422)
         at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:3544)
         at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:2290)
         at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:2232)
         at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:1527)
         at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:1693)
         at oracle.jbo.html.jsp.datatags.CommitTag.doStartTag(CommitTag.java:45)

    Thanks for replay.
    Yes, I use JDev wizard generated BC4J JSP app (it was generated inside 9.0.2 and then migrated to 9.0.3).
    I changed inside it many things, but I thing no important.
    I have for example copying record to history while editing, but when I disable it, the same problem occures.
    I changed database - 8.1.7 to 9.2.0.2.0, but the same problem.
    Any hint?
    Thanks for any comment.

  • Getting the output of a batchfile to Powershell

    Greetings. I have a list of batchfiles that triggers Powershell script, that will throw error message when different errors were encountered in the execution. 
    In the end of the batchfile, I have included:
    if %errorlevel% neq 0 (echo error in previous command & exit /b %errorlevel%)
    and it works fine in itself. 
    However due to some requirements I need to use new separate batchfile that triggers a Powershell, that will in turn lauch the batchfiles mentioned earlier. 
    In the new Powershel, I have included: 
    $process = start-process $batchFile.FullName -ArgumentList $argumentList -PassThru -Wait
    and is able to get $process.ExitCode. However I would like to get the output or error message that would be raised from the first batchfile instead. 
    Any advice?

    Hi Bdrc,
    If you want to capture the output of the batch file, please try to run the batch file like:
    d:\test.bat argu1 argu2
    And the cmdlet start-process will start a process with the batch file.
    For more detailed information, please refer to this article:
    How to Execute a .bat File within a PowerShell Job
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang

  • How to get the output of a standard report  RFBILA00 in PDF form.

    hi,
    I have to get the output of the standard report RFBILA00 in the PDF form.
    Thanks.

    Hi Rao,
    you can run your report RFBILA00 in background  and in background  job you can add one more step, next in that step you can add custom  report like zsubmit .
    job should be set like
    step1:  RFBILA00 with variant.
    Step2:  zsubmit report with variant.
    In Zsubmit report  you can  read, your first step spool using FM GET_JOB_RUNTIME_INFO
    and pass that spool  in the FM  CONVERT_ABAPSPOOLJOB_2_PDF.
    when second  report run in job  you can set your target like download in the server or  send email etc.
    Regards,
    Prasenjit

  • How to get the output of a procedure in to a log file ?

    Hi, Everyone,
    Could you please tell me
    How do i write the output of a procedure to a log file ?
    Thanks in advance...

    Hi,
    could you please explain me more on how to use the UTL_file to get the output to a log file as in am new to PL/SQL
    my script file is
    EXEC pac_sav_cat_rfv.pro_cardbase (200910,'aaa',100,'test_tbl');
    i need the output of this statement in a log file.
    Could you please explain to me how it can be done.
    thanks in advance

  • Is it possible to get the output of a text container into Spool..?

    Hi
    I am trying to write a report for a standard transaction(SM65) in BDC and run thru background job so as to get the output in to Spool. Right now I am facing an issue to get the SM65(text container) tcode output into spool.
    FYI..I am using "CALL TRANSACTION 'SM65' USING BDCDATA MODE 'E'."
    Please provide tour valuable inputs.
    Thanks!
    Shiv

    Hi Shiv,
    Instead of writing BDC for T-code SM65 I would suggest you to use following function module to get the required data.
          CALL FUNCTION 'BPT_ANALYSE_START'
            EXPORTING
              server_name            = servername_tmp
              check_all_btc_servers  = sbpt1020-allsrvchk
              profile_check          = sbpt1020-profilechk
              xpgm_environment_check = sbpt1020-xpgmcheck
            TABLES
              protocol_tbl           = global_protocol_tbl
            EXCEPTIONS
              OTHERS                 = 99.
    Once you got the data into "global_protocol_tbl " you can create spool of it.

  • How can we get the artset from a .ai file without opening it?

    Hello All,
    I have one .ai file, lets say sample.ai file. located in C drive. so the complete file path is "C:\Sample.ai".
    and lets assume the sample.ai file has one traingle shape(3 path type arts) in it.
    Now I want to get the 3 path arts (artset)  from sample.ai file without opening it in AI.
    The function protoype is like below
    AIArtSet& artSet GetArtSetFromAFile( ai::FilePath& filePath );
    Is there any API like above function in AI? or is it possible to get the art(s) from a file without opening it in AI?

    Not to my knowlege. The API only operates on active documents as far as I know.

  • I had to take the I pad I got for Christmas back and they gave me  new one.  Is there a way I can get the books and apps I purchased without having to buy them again?

    I got an I pad for Christmas and had to return it and they gave me a new one.  Is there a way I can get the books and apps I purchased without paying for them again?

    Downloading past purchases from the App Store, iBookstore, and iTunes Store: http://support.apple.com/kb/HT2519

  • NOOB Question - Cannot seem to get the output in a text or CSV file - Please help!!

    I was able to put together a script which finds members of a certain AD group, filters down the users, and then calculates the number of days till a password reset is needed.  I am able to get on screen exactly what i am looking for, but cannot seem
    to figure out how to get the same data to a file.  What i am doing wrong?  two goals here:
    1.  Create a spreadsheet with a list of users whose password is about to expire.
    2.  Down the line automate an email to users whose password is about to expire. 
    Here is my code:
    ## Get List Of Users in Password Change Lockout that do not have an expired password or a password that never expires
    $Names = (Get-ADGroupMember -Identity "Password Change Lockout" -Recursive |`
    Get-ADUser -Properties * |`
    Where-Object {$_.PasswordNeverExpires -eq $False -and $_.PasswordExpired -eq $False} |`
    Sort-Object name |Select-Object -ExpandProperty SamAccountName)
    ## Get Password last Set values for all
    Foreach ($Name in $Names)
    $VAR1 = (Get-ADUserResultantPasswordPolicy -Identity $Name).MaxPasswordAge
    $VAR2 = (Get-ADUser $Name -Properties *).passwordlastset
    $VAR3 = (Get-ADUser $Name -Properties *).name
    $DTPC = (New-TimeSpan -Start (Get-Date) -End ($VAR2 + $VAR1) | Select-Object -ExpandProperty Days)
    Filter users to those who need to change thier password in 15 days.
    If ($DTPC -lt 15)
    No matter what i try between the {} after the If statement, I cannot get the output to a file.  However, if I use a Write-Output I get exactly what i looking for.  I feel like i am forgetting some basic concept and could really use some help.  Thanks.
    Matt 
    Matt Dillon

    Hi Matt,
    I generally create an empty array (something like $out = @()) at the top of the script and then use $out += $desiredOutput inside of the foreach loop.
    Outside of the loop, you can then pipe $out to Out-File or Export-Csv, depending on your needs.
    Don't retire TechNet! -
    (Don't give up yet - 12,830+ strong and growing)

Maybe you are looking for

  • Itunes and windows installation prob...

    I had an older version of itunes and tried to upgrade to 7.1. Everytime I try to download it, I click on the 'itunes setup' icon on my desktop and a 'windows installer' window pops up with a bunch of info that I don't understand. I uninstalled the ol

  • Can you have multiple iCloud's with one Apple ID?

    Can you have multiple iCloud's with one Apple ID?

  • Alternative approach to Migration

    Hello, Our requirement is to go for OS/Db Migration and have the UME Datasource changed from R3 to LDAP Now, since as per SAP, UME Data source cannot be changed from R3 as per note My question is, Is it possible to install the same version of Portal

  • InDesign CS4 not packing fonts

    I'm using InDesign CS4. All of a sudden, a new problem has ocurred. When I package files, the "Fonts" folder is no longer being created with all the fonts used in the file. The "Links" folder is here, but no "Fonts"

  • How do I get my iTunes match "reset" from Apple?

    I would like to have Apple "reset" my iTunes match library. How do I go about requesting this?