Having the ; exit at the end so you terminate the shell process is
brilliant!!!!!
I wish I would've thought of that! :)
Just for the record, it works great!
Thank's a lot!
-Mihai
> Date: Wed, 17 Sep 2008 10:59:06 +0900
> To: [EMAIL PROTECTED]
> CC: [email protected]
> Subject: Re: [JSch-users] How do you capture output of a command executed on
> Shell?
> From: [EMAIL PROTECTED]
>
> Hi,
>
> +-From: Mike V <[EMAIL PROTECTED]> -----
> |_Date: Mon, 15 Sep 2008 21:06:30 +0000 __
> |
> |How do you capture output of a command executed on Shell and how do you
> |know if it is done executing?
> |I need this because some programs look for variables set by the .profile
> |(ksh).
> ...
>
> I have not tried it by myself yet, but ....
>
> /*
> | commandToRun=commandToRun + " > "+tempFile+"\n"
> */
> commandToRun=commandToRun + " > "+tempFile+"; exit\n"
>
> | byte[] bytes = commandToRun.getBytes();
> | ByteArrayInputStream bais=new ByteArrayInputStream(bytes);
> |try { ..... //session connection stuff
> | .....
> | Channel channel=session.openChannel("shell");
> | ((ChannelShell)channel).setInputStream(bais);
>
> InputStream in=channel.getInputStream();
>
> | channel.connect();
>
> byte[] tmp=new byte[1024];
> while(true){
> while(in.available()>0){
> int i=in.read(tmp, 0, 1024);
> if(i<0)break;
> }
> if(channel.isClosed()){
> break;
> }
> try{Thread.sleep(1000);}catch(Exception ee){}
> }
>
>
> Sincerely,
> --
> Atsuhiko Yamanaka
> JCraft,Inc.
> 1-14-20 HONCHO AOBA-KU,
> SENDAI, MIYAGI 980-0014 Japan.
> Tel +81-22-723-2150
> +1-415-578-3454
> Fax +81-22-224-8773
> Skype callto://jcraft/
_________________________________________________________________
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users