Capturing output with exec
Hi everybody!
I'm trying to capture the output of a process that I started using exec(), and I have observed a different behaviour between stdin and stderr.
I have de following C code: (HelloWorld.c)
#include <stdio.h>
int
main(int argc, char **argv)
int i;
for (i=0; i<10 ;i++) {
fprintf(stderr, "HelloWorld stdout\n");
fprintf(stdin, "HelloWorld stdin\n");
sleep(2);
printf("Good bye!\n");
}and to capture output: (TheLaucher.java)
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class TheLauncher {
public static void main(String[] args) throws IOException {
System.out.println("Launcher -- begin");
Process pc = Runtime.getRuntime().exec("HelloWorld.bat");
BufferedReader is = new BufferedReader(new InputStreamReader(pc.getInputStream()));
String line;
while ((line = is.readLine())!=null){
System.out.println(line);
System.out.println("Launcher -- end");
}In this case I have to wait till the end of the process to get the output but if I use the stderr changing:
BufferedReader is = new BufferedReader(new InputStreamReader(pc.getInputStream()));for
BufferedReader is = new BufferedReader(new InputStreamReader(pc.getErrorStream()));I get the strings as they are available.
How can I get the same behaviour with the stdin? Why are they different?
Thanks
Joaquin Morcate
Sorry again the code that I posted was wrong. Instead of
fprintf(stdin, "HelloWorld stdin\n");should be:
printf("HelloWorld stdout\n");I'm not trying to write in stdin but to find an explanation about why this apparently different behaviour of stdout and stderr.
Thanks agian
Joaquin
Similar Messages
-
How to capture output of java files using Runtime.exec
Hi guys,
I'm trying to capture output of java files using Runtime.exec but I don't know how. I keep receiving error message "java.lang.NoClassDefFoundError:" but I don't know how to :(
import java.io.*;
public class CmdExec {
public CmdExec() {
public static void main(String argv[]){
try {
String line;
Runtime rt = Runtime.getRuntime();
String[] cmd = new String[2];
cmd[0] = "javac";
cmd[1] = "I:\\My Documents\\My file\\CSM\\CSM00\\SmartQ\\src\\E.java";
Process proc = rt.exec(cmd);
cmd = new String[2];
cmd[0] = "javac";
cmd[1] = "I:\\My Documents\\My file\\CSM\\CSM00\\SmartQ\\src\\E";
proc = rt.exec(cmd);
//BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader input = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
input.close();
catch (Exception err) {
err.printStackTrace();
public class E {
public static void main(String[] args) {
System.out.println("hello world!!!!");
}Please help :)Javapedia: Classpath
How Classes are Found
Setting the class path (Windows)
Setting the class path (Solaris/Linux)
Understanding the Java ClassLoader
java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run. -
How to replace a "notfound" output with a null value?
hi,
I'm just getting a output of "Rows Notfound" for a script..
instead of this , i just need to show the output with a record as null value or some value..
do we have any option to use this in oracle..Apart from capturing with an exception in PL/SQL code, if you're wanting something in a script as pure SQL, you'd have to generate an additional row and only select that where no data is found e.g...
SQL> ed
Wrote file afiedt.buf
1 select ename from emp where ename = 'FRED'
2 union all
3* select 'No Data' from dual where not exists (select * from emp where ename = 'FRED')
SQL> /
ENAME
No Data
SQL>Of course this does effectively double-up on the queries being executed, so if you're dealing with a heavily complex query, it may be best just just have the regular exception come out, but then this will also depend on your actual requirements and why you want to do this in the first place. -
Excel output (with graphics)
Hello,
I am using Oracle reports 10g 1.2.0 version.
We need to generate oracle reports in Excel format ("real" Excel, not delimited text) with tabular data and
also graphics.
I used desformat=spreasheet. But is is giving only one worksheet.
I've found the "Output to Excel with Oracle9i Reports"
demo but the Excel template in the demo is very simple and doesn't have graphics.
Then I've found the following:
http://otn.oracle.com/products/reports/htdocs/getstart/examples/excel_output/result/excel.jpg
a) The above site has excel output with multiple worksheets.
which is similar to what we need but I wasn't able to find related source (excel_emp.jsp).
b) Using jsp if we can ahieve multiple worksheets with grapahics, please provide us examples.
c) http://www.oracle.com/technology/products/reports/htdocs/getstart/demonstrations/excel/index.html --This site is not working to find the demo.
Could you please help me in this?
Thank you for any help.carla,
the example you mentioned uses the JSP web source that is only available in oracle9i reports.
in theory you can create any excel output. it is just a matter of creating the template and then adding the reports tags to populate it with data.
you could then use reports' URL engine to produce files from this output.
there are certainly ways to do it, but they are only available in oracle9i reports (9.0.2 and higher)
regards,
philipp -
Is it possible to create a Webservice in BI which takes XML as an input and gives PDF as output with an additional requirement that Siebel expecting the XSD from BI to send data in the BI requested format. Siebel wants to send the data as xml to BI but not sure of the BI capabilities on giving WSDL embedded with XSD (input is a hierarchical)
Hi All,
I am able to fulfil above requirement. Now I am stuck at below point. Need your help!
Is there any way to UPDATE the XML file attached to a Data Definition (XML Publisher > Data Definition) using a standard package or procedure call or may be an API from backend? I am creating an XML dynamically and I want to attach it to its Data Definition programmatically using SQL.
Please let me know if there is any oracle functionality to do this.
If not, please let me know the standard directories on application/database server where the XML files attached to Data Definitions are stored.
For eg, /$APPL_TOP/ar/1.0/sql or something.
Regards,
Swapnil K. -
Digital Output With Timer (Simulation)
Hello everyone, I just learned how to make LabVIEW program a week ago. I try to make a simulation of Digital Output by LabVIEW (my attachment). In this simulation I have a slider as an input (0-10 V), two numeric control (upper limit and bottom limit), a waveform chart that plot those 3 value, and two boolean LED (P0.0 and P0.1) as an indicator. In this simulation you can fill any number (between 0-10) in the numeric control as a limit for your slider input. If the input from a slider exceed those upper and bottom limit then the boolean LED will turn on, P0.0 if exceed upper limit and P0.1 if exceed bottom limit. The problem is I don't know how to make timer for those boolean LED. As example:
1) Make an input from slider,
2) If input (1) exceed the upper limit,P0.0 will turn on for 5 second,then turn of for 10 second,
3) If in that 10 second you change the input back to normal (between upper and bottom limit) then P0.0 will stay turn of until the input from slider exceed the upper limit again,
4)If in that 10 second you didn't change the input (stay exceed the upper limit) then P0.0 will repeat the process (2) until you the input from slider back to normal.
(Same process for input that exceed the bottom limit).
Can you help me to make this timer? Thank You (I'm sorry I made a double post):newbie
Regards
Juventom
Attachments:
Digital Output With Timer.vi 16 KBHello Juventom,
As I understand it you want to be continuously checking the value of the sliding bar and comparing that to the upper and lower limit controls whilest also chaning the LED booleans to true for 5 seconds then false for 10 seconds if the sliding bar value is outside of the limits.
To do this you would probably be best using a parallel loop design, where you have 3 while loops in place of the one you have currently. Each one of these while loops would be responsible for a part of your program (e.g. the top one would display your values on the graph and the second one who check the sliding bar value against the upper limit and then turn on the LED, etc)
I've found this tutorial about multiple loop programs and I think you should look at the section entitled "Parallel Execution"
http://zone.ni.com/devzone/cda/tut/p/id/3749
This way you can use normal delay VIs but when they run they only pause that loop rather than the whole program.
Please let me know how you get on with this, and ask me if you need further help.
James W
Controls Systems Engineer
STFC -
Capturing Problem with Sony TRV330
Capturing problem with Sony digital8 trv330.
I recently purchased the above camcorder from eBay for capturing old 8mm/Hi8 tapes for editing purpose. The camcorder set to A/V -> DV OUT connected with Firewire to my Power G4 and the Easy Setup was DV-NTSC. The playback on the capture window looks OK except there were no timecode in the Timecode Duration Field and the Current Timecode Field (both shown 00:00:00:00) during playback but there was timedoce in the camcorder viewfinder. When I click the Capture Now button, the capturing window show up with message “waiting for timecode ….”. I have to click “esc” to stop the capturing operation. I trash the Preferences and Ran the Disk Utility without success. I also tried the Easy Setup with DV-NTSC DV Converter as well as DV-NTSC 32Khz, nothing work.
My set up is: Mac Power G4 version 10.5.5/ F.C.E. 4.0.1/ QT7.5.5/ Startup 160 GB-89 GB available/ Scratch 350GB-277GB available. Folks, I need help. Thanks everybody.Hi, I have a similar problem. I am trying to digitize my 8mm tapes (via firewire) using final cut express (4.0.1). Using easy setup I use DV-NTSC DV Converter and do capture now. I transfer the entire tape but notice the audio is out of synch with the video. This problem gets worse throughout the transfer process. When I use the esc to complete the transfer I get the error " The audio sample rate of one or more of your captured media files does not match the sample rate on your source tape....." So after searching around it is recommended I change the audio sample rate to 32 kHz option. However, when I do this using easy setup and picking DV-NTSC 32kHz I cannot use capture now because I have no timecode and so the window comes up with the message "waiting for timecode". Since there is no timecode this option does not work. Any suggestions? Thanks, Dan
-
How to download alv grid output(with field catalog) into excel file format
Hi all,
How to download alv grid output(with field catalogs) into excel file format and same file has to download to application server.
Please help.
Regards,
Satya.Hi,
On list where alv is displayed, select export icon( green color -> ),select spread sheet.
This will display records in Excel sheet. -
Somebody once asked how to create PDF output with javadoc, so here's some work in progress:
I am currently creating a PDF doclet which creates directly PDF output from javadoc. It's still in alpha stage, because it does not yet create an index or navigation frame (which is mandatory for the PDF to be useful), and most HTML tags are not yet interpreted. But that's gonna improve over the next few weeks.
http://sourceforge.net/projects/pdfdoclet
Bye,
MarcelHai Marcel,
How to run this pdfdoclet?
I tried like:
javadoc -doclet com.tarsec.javadoc.pdfdoclet.PDFDoclet -docletpath d:\For_PDF_Doc\itext-0.92.jar;d:\For_PDF_Doc\pdfdoclet.jar *.java
And the result is:
Loading source file Test.java...
Constructing Javadoc information...
pdfdoclet: >> OPTION 0: -doclet
pdfdoclet: >> OPTION 1: -docletpath
pdfdoclet: Content completed, create index
pdfdoclet: *** PDF DOCUMENT api.pdf COMPLETED ***
Nothing is there in api.pdf!
anu -
Formatted HTML output with Spry regions - is it possible?
I have recently begun using the XML export extension in
conjunction with an Access database to output dynamic data into a
page with a Spry master/detail setup. So far, my simple example is
going great, but I've run into a snag that I need some help with.
To explain what I'm doing - it's a simple article page with
the list of articles on the left with the title and date and the
article title and full contents on the right hand side. So far it's
all working very well, updating in real time when I click an
article title on the left. The problem is the output with this one
field which stores not only text, but also HTML formatting that is
generated by a wysiwyg editor used on the article creation side of
this little app. This HTML formatted content is the article body
and is stored in a field named the same - "body". With traditional
ASP, the HTML formatting displays as expected and all is well, but
with Spry, it doesn't output formatted HTML, but instead shows the
content and HTML code together as text. How can I get this one
field ("body") to be output so all the HTML formatting is shown?
This is my simple page example. Click through and you'll see
what I mean.
http://www.shoestodyefor.com/ajax.asp
Here's the section of code in question regarding the output
on that right hand panel where the body is displayed for each
article:
<div spry:detailregion="ds1">
{title}<br />
{entryDate}<br />
<br />
{body}
/div>
Is it possible to have that {body} section shown so the
dynamically created HTML code from the wysiwyg editor is displayed
correctly?Steve Skinner wrote:
> Is it possible to have that {body} section shown so the
dynamically created
> HTML code from the wysiwyg editor is displayed
correctly?
The version of Spry that ships with Dreamweaver CS3 (Spry
1.4) doesn't
support the type of output created by the XML Export
extension.
This issue has been corrected in Spry 1.5, but no plans have
been made
public for integrating Spry 1.5 into Dreamweaver CS3. You
would need to
download Spry 1.5 from
http://labs.adobe.com/technologies/spry/.
Details
of how to hand-code the fix for output from XML Export are
here:
http://labs.adobe.com/technologies/spry/samples/data_region/HTMLFragsInXMLSample.html
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/ -
Stored Procedure, "WITH EXEC AS CALLER"
I'm reviewing a stored procedure some one else wrote.
Right before the variable declarations (DECLARE) and right after the parameters they wrote the following:
WITH EXEC AS CALLER
AS
What does this do, exactly? I've looked at stored procedure tutorials and examples and none of them use this.
Here is more of the code snippet if need be.
USE [Database1]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[RagGetIt]
@initials nvarchar(3), @state nvarchar(2)
WITH EXEC AS CALLER
AS
DECLARE
@var1 INT,
@var2 INT,
@var3 INT,
Also, is there a point of having those three 'GO' statements in the beginning, or is GO just supposed to go at the end of the procedure's code?
-Nothing to see. Move along.http://lmgtfy.com/?q=with+exec+as+caller+mssql
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question. -
Regarding ALV outputs ( with layout variants)
Hi,
I have a problem where in an ALV report when it is executed with a variant (there is one layout parameter in the screen which is also filled. This layout is set with a filter),
displays the output. But the displayed output doesn't filter the output as per the required criteria set in the layout filter.
When I execute the report with the same variant but now if I select the layout by pressing F4 on the layout field and select the same layout as earlier (which is having the filter criteria), now it displays the output as per the required criteria set in the filter.
I don't understand why if I execute the report with a variant with the layout value also filled, it is not able to give the required output as per the filter criteria set for the layout.
When the report is executed with the same variant but the layout value selected from F4, it dispalys the correct output with the filter criteria set for the layout.
In general, I mean why the program is not able to load the layout with filter when it is called from a variant?
Regards,
RajeshIt depends on your Layout, How you saved it .
And one more question are you passing the layout parameter and Filter parameter to the Function module -
Process the output with dispatch time 3
Dear experts!
Thank you for your attention!
I ues output type BA00 to print order confirmation and set the dispatch time 3
after i save the order, where can i process the output?
as in delivery output, we can use VL71 to process outbound delivery.
which t-code could i use to process the order output with dispatch time 3 ???
Best regard!
Tangdarkis there anyone can help???
please~~~ -
PO output with XML and PDF format
Hi All,
I need PO output with XML and PDF format. when I give print it shld go to vendor with xml and pdf format through mail. please kindly guide me on this .
Thanks in advance
JKhi,
try this code to get in pdf form
REPORT zsuresh_test.
Variable declarations
DATA:
w_form_name TYPE tdsfname VALUE 'ZSURESH_TEST',
w_fmodule TYPE rs38l_fnam,
w_cparam TYPE ssfctrlop,
w_outoptions TYPE ssfcompop,
W_bin_filesize TYPE i, " Binary File Size
w_FILE_NAME type string,
w_File_path type string,
w_FULL_PATH type string.
Internal tables declaration
Internal table to hold the OTF data
DATA:
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
Internal table to hold OTF data recd from the SMARTFORM
t_otf_from_fm TYPE ssfcrescl,
Internal table to hold the data from the FM CONVERT_OTF
T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
This function module call is used to retrieve the name of the Function
module generated when the SMARTFORM is activated
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = w_form_name
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = w_fmodule
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Calling the SMARTFORM using the function module retrieved above
GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
format of the output
w_cparam-no_dialog = 'X'.
w_cparam-preview = space. " Suppressing the dialog box
" for print preview
w_cparam-getotf = 'X'.
Printer name to be used is provided in the export parameter
OUTPUT_OPTIONS
w_outoptions-tddest = 'LP01'.
CALL FUNCTION w_fmodule
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
control_parameters = w_cparam
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
output_options = w_outoptions
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = t_otf_from_fm
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
t_otf[] = t_otf_from_fm-otfdata[].
Function Module CONVERT_OTF is used to convert the OTF format to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = W_bin_filesize
BIN_FILE =
TABLES
otf = T_OTF
lines = T_pdf_tab
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
To display File SAVE dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION =
DEFAULT_FILE_NAME =
FILE_FILTER =
INITIAL_DIRECTORY =
WITH_ENCODING =
PROMPT_ON_OVERWRITE = 'X'
CHANGING
filename = w_FILE_NAME
path = w_FILE_PATH
fullpath = w_FULL_PATH
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
presentation server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_bin_filesize
filename = w_FULL_PATH
FILETYPE = 'BIN'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = T_pdf_tab
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
reward points if useful,
siri -
Can we Compare PDF Output with CSV format
Team,
Can we Compare PDF Output with CSV format.
In Excel I need to two text boxes asking us to browse the files and compare the files PDF & CSV format.
Please suggest me if we have solution for this.
Thanks!
KiranHi
I'm afraid the Excel Application does not support this function currently, I am suggesting you to take advantage of a third party component to achieve this goal.
Thanks for your understanding.
Best Regards
Lan
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Maybe you are looking for
-
How can I remove the Yahoo icon from my iphone?
How can I remove the Yahoo icon from my iphone?
-
Why can I no longer upload a picture to Facebook for my profile
why can I no longer upload a picture to my Facebook for my profile
-
Updating using java script and jQuery
Is it possible using javascript and jQuery to update the two forms of this page, in tandem as the fields change? http://www.milesmemorials.com/product-GH54.html As you can see there are two forms, the first holds all the element choices and has an '
-
Help: Controlling transitions in flash web galleries from CS4/Bridge
Hi all, Is there a way to control the transitions from one image to the next when generating a flash web gallery? I'm using CS4/Bridge on WinXP. The fade out/in from one image to the next is very chunky, no matter what the file size. And that's on m
-
Internet Explorer 5.1.7 Freezing / crashing/ out of memory
I have regular crashes, randomly from 5 to 120 mins when on the internet. I have a G3 blue and white with 350mhz processor running 9.2.2 with 512Mb ram. Internet Explorer 5.1.7. I have always had problems with crashing on this machine even from new w