Duh - I can't see the output because it's in another process??

I've been banging my head, trying to learn how to make Unix scripts and Java work together. At my job there's a lot of that, and I'm an intern and wanting to learn more so I've been playing at home. I have a Linux (RedHat7.2) partition at home, so I get that out in the evenings and play.
I just learned there's a Runtime.exec() that can call applications. Cool. But I wanted to see if I could write a shell script and call that. I can get a regular application like gedit to open up, with
Runtime.getRuntime().exec("gedit");
But following the examples I found on forum searches, I can't get
Runtime.getRuntime().exec("/bin/csh" "/root/testscript.sh") to show any output.
I've been working in a terminal all along, and it just dawned on me that since exec() spawns a process, I could see with ps if it happened. Sure enough, every time I run
java foo
a new csh process starts. But still no output on the terminal. testscript.sh just says
echo Hello world
So I figure that the process is there and it did run the script, but it can't use the current terminal window for its output.
If this is right, is there some way I can add something to foo.java that will kick off a terminal for the new csh process to use for its output?
Thanks, this is fun!

So do you want a new xterm or aterm or Eterm or wterm or what-ever-term window to pop up or just execute the script so that its stdout goes to java's stdout?
This works but it is not complete:      1 import java.io.InputStream;
      2 public class testexec {
      3
      4     public static void main(String[] args) throws Exception {
      5         // Execute command
      6         String[] command = {"/bin/sh", "-e", "/home/myusername/hi"};
      7         Process child = Runtime.getRuntime().exec(command);
      8
      9         // Get input stream to read from it
     10         InputStream in = child.getInputStream();
     11         int c;
     12         while ((c = in.read()) != -1) {
     13             System.out.print((char)c);
     14         }
     15         in.close();
     16     }
     17 }(not complete because in real life there could be output in stderr too, and you need to watch both streams)
and the script file "hi" goes:#!/bin/sh
echo "Hello World!"

Similar Messages

  • I try to find something on my iPad, many results are emails, when I push on an email I can't see the email, because I get ever the first email,or the previous selected email in my inbox. How can I see the email selected?

    I try to find something on my iPad, many results are emails, when I push on an email I can't see the email, because I get ever the first email,or the previous selected email in my inbox. How can I see the email selected?

    Is your Yahoo account set up as POP3 or IMAP?

  • How can i see the output of a form

    I am having one driver program and form.From these two how can i see the output.

    Hi Sunny
    You might already know; but for the driver program; a smartform is just a function module.
    (In the smartform; this function module name can be found in the menu tab Environment -> Function Module Name.)
    Note: The FM 'SSF_FUNCTION_MODULE_NAME' is obviously the correct way of getting the FM name from the smartform name !!
    So all you need to do is call this function module passing any variable / tables you need to pass to the smartform from your driver program.
    Hope it helps
    Neer

  • Can't see the output of cast/multicast

    Hi, I can't see the output of cast/multicast.. but in sql*plus, i can..
    regards

    Hello, here's a sample...
    ops$rringor@RLR9204> create or replace type
    2 myarraytype as table of varchar2(2000)
    3 /
    Type created.
    ops$rringor@RLR9204> drop table t;
    Table dropped.
    ops$rringor@RLR9204> create table t
    2 ( id number not null ,
    3 name varchar2(10) ) ;
    Table created.
    ops$rringor@RLR9204> begin
    2 for i in 1..10
    3 loop
    4 insert into t values ( i, i||'abc');
    5 end loop;
    6 end;
    7 /
    PL/SQL procedure successfully completed.
    ops$rringor@RLR9204>
    ops$rringor@RLR9204> select a.id,
    2 CAST( MULTISET( select b.name
    3 from t b
    4 where b.id = a.id ) as myArrayType ) as names
    5 from t a ;
    ID NAMES
    1 MYARRAYTYPE('1abc')
    2 MYARRAYTYPE('2abc')
    3 MYARRAYTYPE('3abc')
    4 MYARRAYTYPE('4abc')
    5 MYARRAYTYPE('5abc')
    6 MYARRAYTYPE('6abc')
    7 MYARRAYTYPE('7abc')
    8 MYARRAYTYPE('8abc')
    9 MYARRAYTYPE('9abc')
    10 MYARRAYTYPE('10abc')
    10 rows selected.
    I can see the records under NAMES but I can't view it using SQLDeveloper.

  • Live tracing a white png logo in Illustrator CC - can't see the results because of white Artboard

    Hi, I am fairly new to Illustrator. I have a white png logo (with transparent background) that I need to Image Trace to create a vector version of it. However every time I import the png into Illustrator it opens it on a white artboard so I cannot see the logo. I cannot see any options to change the transparency of the artboard. Does anyone know the best way to overcome this?

    I believe the last word in post #2 should be trace.
    Actually not, because you first need to rasterize before you can trace.

  • How can i see the output in Visual Studio 2013

    Below is some code rearrange a array, i want to see the result after it's sorted so i add a loop of cout myself, But after runing the code, nothing happened, i didn't see any result from the widow before it closed, any help?
    #include<iostream>
    const int Red = 1, White = 2, Blue = 3;
    void main()
    int arr[] = { 1, 1, 2, 2, 1, 3, 1, 2, 3, 3, 1, 1, 3, 2, 1, 2, 1, 3, 2, 1, 1, 3, 2, 1, 3, 1, 3, 2, 2, 3, 3, 3, 1, 2, 1, 2, 1, 3, 1, 2, 3, 3, 1, 2, 1, 2, 1, 2, 2, 1 };
    int n = sizeof(arr) / sizeof(int);
    int Insert_Red = 0, Insert_White = 0, i;
    for (int i = 0; i < n;i++)
    if (arr[i]==White)
    arr[i] = arr[Insert_White];
    arr[Insert_White] = White;
    Insert_White++;
    if (arr[i]==Red)
    arr[i] = arr[Insert_White];
    arr[Insert_White] = arr[Insert_Red];
    arr[Insert_Red] = Red;
    Insert_Red++;
    Insert_White++;
    for (int i = 0; i < n; i++)
    std::cout << arr[i];

    i didn't see any result from the widow before it closed
    Other choices which don't require any changes to your code:
    (1) Set a breakpoint at the last closing brace (assuming that there isn't a
    return statement before it - if there is then set the breakpoint on that
    return statement).
    (2) Put the cursor as described in (1) but instead of setting a breakpoint
    use "Run To Cursor" from the menu that pops up when you right-click the
    mouse. (Or use Ctrl-F10)
    (3) Run your program in the IDE using Ctrl-F5 (Run Without Debugging)
    Note that when using these methods, focus *may* remain on the IDE editor. If it
    does then your console window with the output will be a background window. You
    will then need to switch to it manually from the Taskbar, etc.
    Non-related observation:
    Standard C and C ++ require that the main() function return an int. e.g. -
    int main()
    Some compilers will accept void main() so as not to break old code, but new
    code should always return an int.
     - Wayne

  • Can't see the output window in Ultiboard 2001 SP2

    I have been running Ultiboard 2001 for many years, as it is adequate for my needs. I recently had a HD crash on my old laptop, and had to re-install the UB 2001 software on my new laptop (Dell E-series, Windows XP, SP3). All is basically OK, except that I cannot get the Output window to disply, so I am unable to see any DRC checking info, connectivity errors, etc. The Output window is checked in the View menu, but checking or unchecking makes no difference. I have Ultiboard 2001, SP2. All other windows & toolbars seem to display correctly.

    Hi Dave,
    It is possible that the Output window was dragged outside of the Ultiboard screen.  Have a look at the attached screen shot, notice a small Output window outside, if you see something like it, drag it back inside.
    Tien P.
    National Instruments
    Attachments:
    Output.png ‏835 KB

  • Where can I see the output of System.out.println for iWS 4.1 on NT

     

    I hope these two kb articles would help you to see the answer.
    http://knowledgebase.iplanet.com/ikb/kb/articles/4790.html
    http://knowledgebase.iplanet.com/ikb/kb/articles/4235.html

  • Spool file problem,Can't see the query in output file.

    Hello ,
    I am facing a very old school kind of problem .....about spool file ....
    The scenario -
    I have made a script by name DB_Status_checkup.sql which i want to fire on the database to check the database status. In this script their are many queries regarding the data dictionary views to know about the database. It consist of nearly 25-30 different select queries..
    The problem is i want to make a spool file of the output of that query....i want to see the SQL query & the output below in the spool file, so it will be easy for me to judge the result. But i can't see the SQL query , i can only see the output , & in so many queries it all gets jumbled up....even i can't understand where the next output starts ...
    Sample of my SQL Script ....
    clear buffer
    spool D:\DB_status.txt
    /*To check the database startup time*/
    Select to_char(startup_time, 'HH24:MI DD-MON-YY') "Startup time"
    from v$instance
    .........next query n so on....
    spool off;
    In the output pf the spool file at D:\db_status.txt..
    Startup time
    08:25 16-JUL-10It shows only the output of the query in the spool file not the query,
    What should i do to get the SQL query as well as the output of that query just below it in the spool file ???
    Please suggest if you have anymore ideas , regarding this .....
    ORACLE 10g R2
    Windows Server 2008
    Thanks in advance ...

    Why don't you just use database control, instead of re-inventing the wheel?
    Apart from that, SQL*Plus has it's own reference manual, which you apparently refuse to read.
    The answer to your quiz/doc question is
    set echo on
    Sybrand Bakker
    Senior Oracle DBA

  • Final user's can not see the data due to limited authorization.

    We have created a InfoSet with three info Objects, 0Account, 0Costcenter and 0COMP_CODE. 0Costcenter have an attribute retail location  0RT_LOCATIO.
    0RT_LOCATIO is an authorization relevant object. We as consultants can execute the infoset properly, but final user's with limited authorizations can not see the data because of authorization failier
    We hae several options to solve the issue, deleselect the auth. flag in the infoobject; delete the infoobject from the attributes of the cost center or create an authorization object and assign it to the final user's profile. But we don't want to go that way.
    My question is, is there any way to avoid including this attribute in the infoset definition? We are not using it in the query and we don't need it, so if we could delete it from the infoset (in the same way you add or delete infoobjects from an Infocube) without changing the cost center aster data, we will have our problem solved.
    Does anyone how to do this (if possible)?
    Thanks in advance!

    Just do two things to find the authorization check failed for that user.
    1. Execute SU53 output and find out the authoirzation check failed. If yes, please send that to BASIS Team.
    2. Next one, switch on the authorization trace in ST01 and ask that user to see that data. if the user is failed with authorization issue. switch off the trace in ST01 and find out the issue.
    Do this way, if it is not successful you can go for any other alternate way.
    Hope this would help you.

  • Where to see the output of batch file run in java

    I use RunTime.getRunTime.exec() to run a batch file, it seems going fine. But I can not see the output of the batch file. For instance, the batch file is to print sth on the screen, but it wont display under java.
    Why and how?
    Thanks

    You get the Process and from that yoo use getInputStream().
    You need to read the stream in a seperate thread since if it fills the buffer it blocks the thread (which would be your main thread.)

  • How can i see the "manage devices" in my itunes account? because i want to remove a device from using my apple id. tnx so much

    how can i see the "manage devices" in my itunes account? because i want to remove a device from using my apple id. tnx so much

    Thanks pvonk, I will try downloanding the book from the Iphone right now.......
    Just tried to download and it wants me to buy it again?  Is there some way around this?  I guess I thought that was the whole point of the cloud, buy it once and access from any of your devices right?
    Also, I have logged into the icloud.com as suggested and will plink around there for a bit and try to understand.  It is just all so dang different that what I am used to; Apple's way, that is.
    Thanks again for the Icloud tip and if you know of a way to download without making a 2nd purchase I would sure love to hear it!
    Geez. one other thing (I guess I am complaining) but I bought more space in the cloud, they took my cash fast enough but have not yet increase the size of my storage space yet?  Is Apple sometimes slow to get internal stuff done?

  • HT4061 I was working on Setting and there was an option ''Zoom''. I made it enable and there after whole screen has been 10 times larger. Now I can Not do anything, even can't open my phone anymore because I can't see the sliding option due to extra large

    I was working on Setting of my iphone4S, and there was an option ''Zoom''. I made it enable and there after whole screen has been 10 times larger. Now I can Not do anything, even can't open my phone anymore because I can't see the sliding option due to extra large screen. Please help me.

    Did you try to tap using three fingers?
    Turn Zoom on or off. Go to Settings > General > Accessibility > Zoom. Or, use the Accessibility Shortcut. See Accessibility Shortcut on page 123.
    Zoom in or out. Double-tap the screen with three fingers.
    copied from page 134 of the user guide iOS7

  • Hi, I have a problem with fonts because in the window I can't see the font, they are transparent. how can I fix this?

    Hi, I have a problem with fonts because in the window I can't see the font, they are transparent. how can I fix this?

    giadad,
    It sounds as this issue:
    Open System Preferences and go to Accessibility. Next, select Display from the source list along the left, then check the box labelled Reduce transparency.
    It was first presented in this post #15 by TheUlser:
    https://forums.adobe.com/message/6854594#6854594
    It has been described on this Adobe page:
    http://capitalmacservice.com/font-preview-working-illustrator-cs-5-yosemite-fix/

  • I have transefer function like (1/(s^2+s+​5)) and i have a square wave input , i want to use this transfer function with this input to see the output , how can i do that , with example please.

    i need to know also how to represent this transfer function in labview, try to send me example. answer me at my mail

    "st" wrote:
    > answer me at my mail
    give a valid e-mail first, and your name, we don't like to help anonymous
    people
    > try to send me example.
    how much do you pay ?
    > i have transefer function like (1/(s^2+s+5)) and i have a square wave
    > input , i want to use this transfer function with this input to see
    > the output , how can i do that
    First you have to know what you are doing, like an engineer : you have a
    Laplace, continuous time transfer function but LabView handles discrete
    signals only. Use matlab/simulink if you want to simulate continuous time
    systems easily...
    If you definitely want to use LabView, the first step is to discretize your
    continuous-time transfer function, i.e. decide a sampling rate and convert
    it to a "z transfor
    m". Then you can directly use the "IIR Filter.vi" as I
    said earlier.
    Philippe Guglielmetti - www.dynabits.com me at my mail

Maybe you are looking for