Capturing output of commands

Hello,
How do I capture the ouput of commands?
When I type in state('Server') it prints out immediately.
I did try redirecting output but it did not work. Any other wat I can do this.
#Redirect output to a tmp file
tmp_file = open('tmp.log','w')
sys.stdout = tmp_file
print "\n\nOur Final List of Servers:"
state('server1')
I get only "" Our Final List of Servers: "" in tmp.log
The command output for state gets printed in the shell...

Hello Vamsi,
After looking at it further I realise that wlst is not directing the
output to the specified output stream. This should be fixed in the next
release of wlst (probably in a month)
Thanks,
-satya
Vamsi wrote:
Hi Satya,
theInterepreter.setOut() function doesn't help in redirecting..
I did:
#Redirect output to a tmp file
tmp_file = open('tmp.log','w')
theInterpreter.setOut(tmp_file)
print "\n\nOur Final List of Servers:"
state('server1')
But I see only 'Our Final List of Servers:' in the tmp.log file.
The state of server1 still prints to the command shell!!!
Any help is greatly appreciated.
Thanks in advance,
-Vamsi
"Vamsi" <[email protected]> wrote:
Hi Satya,
I tried it. But I do not see any return value from the state('server')
in my tmp
file.
If I do:
print "Our final list of Servers:" + state(server)
I see "Our final list of Server:None".
Satya Ghattu <[email protected]> wrote:
Vamsi,
You could do something like this,
#Redirect output to a tmp file
tmp_file = open('tmp.log','w')
theInterpreter.setOut(tmp_file)
print "\n\nOur Final List of Servers:"
state('server1')
Thanks,
-satya
Vamsi wrote:
Hello,
How do I capture the ouput of commands?
When I type in state('Server') it prints out immediately.
I did try redirecting output but it did not work. Any other wat I
can
do this.
#Redirect output to a tmp file
tmp_file = open('tmp.log','w')
sys.stdout = tmp_file
print "\n\nOur Final List of Servers:"
state('server1')
I get only "" Our Final List of Servers: "" in tmp.log
The command output for state gets printed in the shell...

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.

  • Capturing file place command

    I am placing a word document using File->Place command. I want to capture file place command as I have to show a dialog just after a file is placed.
    I have a attached an observer to document.In Update() method I have written following code :
    ICommand* cmd = (ICommand*)changedBy;
    ClassID cmdClass = ::GetClass(cmd);
    ICommand::CommandState cmdState = cmd->GetCommandState();
    do
        if( cmdClass == kPlacePICmdBoss && cmdState == ICommand::kDone )
              this->ShowDialog();
    }while(kFalse);
    When I run my plugin dialog is shown two times after placing document ,which should not happen. How I  show my dialog just once.
    When debugging call is going inside if block two times.(Therefore 2 dialogs are shown).
    Also when I place document other way round i.e first create a text frame and then place document . In that case I am not able to capture file place command.
    I also tried to apply resonder for file place signal , but that is also working in only one case(i.e second one and not first one)
    Please help me out.

    I am placing a word document using File->Place command. I want to capture file place command as I have to show a dialog just after a file is placed.
    I have a attached an observer to document.In Update() method I have written following code :
    ICommand* cmd = (ICommand*)changedBy;
    ClassID cmdClass = ::GetClass(cmd);
    ICommand::CommandState cmdState = cmd->GetCommandState();
    do
        if( cmdClass == kPlacePICmdBoss && cmdState == ICommand::kDone )
              this->ShowDialog();
    }while(kFalse);
    When I run my plugin dialog is shown two times after placing document ,which should not happen. How I  show my dialog just once.
    When debugging call is going inside if block two times.(Therefore 2 dialogs are shown).
    Also when I place document other way round i.e first create a text frame and then place document . In that case I am not able to capture file place command.
    I also tried to apply resonder for file place signal , but that is also working in only one case(i.e second one and not first one)
    Please help me out.

  • Details about the packet capture output bits...

                       Hi Mates,
    If we take the packet capture output, we will get similar output as follows:
    Please explain the significance of the highlighted bits values. (S,P,F and . )
    If tehre is ny doc related to them, appreciate to share.
    Thanks & Regards
    Ramana

    S SYN
    P PUSH
    F FIN
    http://www.firewall.cx/networking-topics/protocols/tcp/136-tcp-flag-options.html
    Looking for some Networking Assistance? 
    Contact me directly at [email protected]
    I will fix your problem ASAP.
    Cheers,
    Julio Carvajal Segura
    http://laguiadelnetworking.com

  • 1.how can I interpret meaning of TARGET  STATE   in output of command crsctl stat res -t  2. what exactly is nodeapps and why it need to be stopped before any maintenanace activity.

    I have two question requesting from the Gurus.
    1.how can I interpret meaning of TARGET  STATE   in output of command crsctl stat res -t  2. what exactly is nodeapps and why it need to be stopped before any maintenance activity. 

    I'd tried deleting my user preferences before, and it didn't seem to help. However, I tried again, and also removed the couple of actions I'd had in ~/Library/Automator. Success! Just for good measure, I tried putting the actions back and restoring the old preferences file, and everything still worked. Huh. But that's the nature of these things, I guess. At least it works now, thanks!

  • 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

  • How to capture output when exectuing an external command?

    Hey guys,
    I am executing the following piece of code:
    try {
    Process proc = Runtime.getRuntime().exec(execute);
    BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    String s;
    while ((s = br.readLine ())!= null){
    System.out.println(s);
    catch (IOException e) {}
    Now, I am executing the cmd.exe under Windows 2000 and using it to perform file operations. However, in cases where there is an error message (ie. file does not exist) I do not get any output back on the screen. For some reason it seems to be causing an exception. Does anyone know how I can capture the output or what might be wrong with my current code?
    Thanks.

    You just captured the "inputStream" There is an error stream too :)

  • How capture output of DBCC command in new table?

    The dbcc sqlperf(logspace) statement returns the "Log Size (MB)" column indicating the physical size on disk of the transaction log for a given database.   How can I capture that Log Size field into in my own table where I can
    manipulate it?
    TIA,
    edm2

    Try the below to know the exact data types:
    create table TmpLOGSPACE(
    DatabaseName sql_variant
    , LOGSIZE_MB sql_variant
    , LOGSPACE_USED sql_variant
    , LOGSTATUS sql_variant)
    insert TmpLOGSPACE(DatabaseName, LOGSIZE_MB, LOGSPACE_USED, LOGSTATUS)
    EXEC('DBCC SQLPERF(LOGSPACE);')
    SELECT SQL_VARIANT_PROPERTY(DatabaseName,'BaseType') AS 'Base Type',
    SQL_VARIANT_PROPERTY(LOGSIZE_MB,'BaseType') AS 'LOGSIZE_MB',
    SQL_VARIANT_PROPERTY(LOGSPACE_USED,'BaseType') AS 'LOGSPACE_USED',
    SQL_VARIANT_PROPERTY(LOGSTATUS,'BaseType') AS 'LOGSTATUS'
    FROM TmpLOGSPACE
    select * from tmpLogSpace
    drop table tmpLogSpace

  • How to capture output from Runtime.exec() ?

    Hi,
    Well, the question is in the subject ...
    I'd like to capture the output of a process ran by Runtime.exec() in order to process it.
    thanks,
    ionel

    Okay ...
    Sorry for the post !
    I found the solution : Runtime.exec().getOutputStream()
    Thanks however
    ionel

  • Field that is Calculated - Read Only - Capturing output in XML after?

    Hello:
    I have defined a Calculated - Read Only field but I have not successfully bound it or captured its value in XML.
    In my Object Palette I do not have a Binding tab, so how do I capture its value in XML after?
    Thanks,
    Newbie in Adobe

    Unfortunately the fields you included in that Import/Export were text fields and thus had the Binding tab available in the Object Palette.
    Fields that are of type Calculated - Read Only do not have the Binding tab, so to get around that, I defined my variable to be Read Only, and added my calculation to the calculate script. The Binding tab was available and thus allowed me to bind my output.
    Problem solved.
    Thanks anyways,
    Newbie in Adobe

  • How to Capture the user command value instead of ucomm and pfkey from syst

    Hi,
    How to capture the value of enter key in the enhancements.
    Iam getting the sy-ucomm value as space. Please let me know the better solution ASAP.
    regards
    Nagendra

    Hello,
    If is a module pool program, take a look to the variable defined to receive the user-command (you can see this in the screen painter).
    Regards.

  • Problem on  "at selection-screen output." command

    Hi ,
    in my programe a part of code is :-
    selection-screen : begin of block b0 with frame title text-000.
       selection-screen:  skip 1.
      parameters: s_box1  radiobutton group g1 user-command u1  default            'X',
                  s_box2 radiobutton group g1.
    selection-screen : end of block b0 .
    selection-screen : begin of block b2 with frame title text-002.
    select-options  : s_vend for bseg-lifnr modif id m1 .
    selection-screen : end of block b2 .
    selection-screen : begin of block b3 with frame title text-003.
    select-options  : s_budat for bkpf-budat modif id m2 .
    selection-screen : end of block b3 .
    at selection-screen output.
    if s_box1 = 'X'.
    loop at screen.
    if screen-group1 = 'M2'.
    screen-active = '0'.
    modify screen.
    elseif  screen-group1 = 'M1'  .
    screen-active = '1'.
    modify screen.
    endif.
    endloop.
    elseif s_box2 = 'X'.
    loop at screen.
    if screen-group1 = 'M2'  .
    screen-active = '1'.
    modify screen.
    elseif  screen-group1 = 'M1'.
    screen-active = '0'.
    modify screen.
    endif.
    endloop.
    endif.
    while executing this one...
    while clicking S_BOX2 from S_BOX1 , S_VEND is changing to S_BUDAT but if I click again S_BOX1 this program goes to infinite loop.
    Please help me to correct this problem.
    Thankx in adv.
    Biswajit
    N.B:- This is a test code. no coding convention  is followed.

    I just copied your code and Tested it is working fine with out any problem.
    REPORT  zscreen_test_.
    TABLES:bseg,bkpf.
    SELECTION-SCREEN : BEGIN OF BLOCK b0 WITH FRAME TITLE text-000.
    SELECTION-SCREEN: SKIP 1.
    PARAMETERS: s_box1 RADIOBUTTON GROUP g1 USER-COMMAND u1 DEFAULT 'X',
    s_box2 RADIOBUTTON GROUP g1.
    SELECTION-SCREEN : END OF BLOCK b0 .
    SELECTION-SCREEN : BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    SELECT-OPTIONS : s_vend FOR bseg-lifnr MODIF ID m1 .
    SELECTION-SCREEN : END OF BLOCK b2 .
    SELECTION-SCREEN : BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
    SELECT-OPTIONS : s_budat FOR bkpf-budat MODIF ID m2 .
    SELECTION-SCREEN : END OF BLOCK b3 .
    AT SELECTION-SCREEN OUTPUT.
      IF s_box1 = 'X'.
        LOOP AT SCREEN.
          IF screen-group1 = 'M2'.
            screen-active = '0'.
            MODIFY SCREEN.
          ELSEIF screen-group1 = 'M1' .
            screen-active = '1'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSEIF s_box2 = 'X'.
        LOOP AT SCREEN.
          IF screen-group1 = 'M2' .
            screen-active = '1'.
            MODIFY SCREEN.
          ELSEIF screen-group1 = 'M1'.
            screen-active = '0'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    "If you have any code next to this place that under appropriate
    "events.

  • Capture output myPage.jsp and send by email

    Hi all,
    I'm trying to capture HTML output produced by myFirstPage.jsp and then send it by java mail.
    The first problem is : How can I capture the output?
    Is right to call myFirstPage.jsp from another jsp page (by use HttpURLConnection) and then write a myOutput.hml file?
    Moreover,the second problem is : How can I send Html file with all images incluted?
    I read about use CID, but how can I read dynamically Images from HTML file and replace the Path with a CID Reference and then put all HTML file in messageBodyPart ??
    Thanks in advances
    Francesco.

    The first problem is : How can I capture the output?
    Is right to call myFirstPage.jsp from another jsp page (by use HttpURLConnection) and then write a myOutput.hml file?That would work.
    But there is a better way.
    You can use a javax.activation.URLDataSource for your Email.
    DataSource mailContent = new URLDataSource("http://localhost/myFirstPage.jsp");
    That will connect to the URL, and use the result as the body of the message.
    Sorry, don't know about including the images as well.
    Cheers,
    evnafets

  • Screen capture output is cropped incorrectly

    I'm using the built-in screen capture functionality on OS X to grab screenshots, using Command-Shift-4 followed by space, then clicking on the window to be captured.  The problem is that if the window fills the full screen area, it is partially cropped at the right side and bottom (see example image).
    This problem appears to relate to the screen capture grabbing the drop shadow in addition to the window itself.  If I reduce the window size to allow a decent margin around it, I can capture an uncropped image – but then the window size is smaller than I need it to be for the image I want.  Also, I would like to capture the window ONLY, without the drop shadow.
    Does anyone know how to fix this problem?  And for bonus points...is there an option to capture a window WITHOUT the drop shadow?  I know I can used the Command-Shift-4 and drag out a capture area, but this almost always results getting unwanted borders somewhere (since I can't accurately spot and click on the exact edges).

    See https://discussions.apple.com/message/8007049#8007049 for a way to turn off the drop shadow in captures.
    Message was edited by: R C-R

  • How to pause output in command prompt

    I have 10 sentence for instance, i want to display one sentence each time i press enter. Does anyone know how to do it in java?(command prompt)

    1. Wrap the default System.err and System.out in your own PrintStreams
    2. Replace them with your wrapper classes (see System.setErr(PrintStream) etc)
    3. In the wrapper classes, parse output looking for '\n' chars + any time you find one, write to that point, then read a return from System.in

Maybe you are looking for

  • Data-sources.xml

    Hi All, In the 'Connections-Navigator' I have made some database connections, when I deploy my application JDev creates a file data-sources.xml ant put it under META-INF directory of ear file. But I am not able to see this file anywhere in my source

  • Clustering and HA for the CM SDK in iAS

    We are currently using iFS 9.0.1 on a 9.0.1 Database with an application using the iFS 9.01 API's ruining in a OC4J 9.0.3 container (using java 1.3.1). We are going to move to iAS 9.02/9.0.3 and would like to known if the latest CM SDK (9.0.3) that r

  • Live correcting color on multiple Mini DV cameras and MBP?

    I'm looking for a solution. I am a wedding videographer, I shoot with a Canon XL1s, Canon GL2, and sometimes another Canon camera (model changes). What i am looking for is a way to plug the cameras into my macbook pro and be able to calibrate the col

  • Table Name which contains Role for a Query

    Hi Please let me know if there is any table present where i will give Query name as Input and i will get the Role name for that query. Regards Atul

  • Report is showing extra lines in output

    Hi, I have a Account Receiving Report. My problem is that in report i have 2 radio buttons..First is for Base Line date and Second for Due date. When i execute the report from both the options, data is coming same.. Means in Due Date column, date is