サーバーに telnet で接続し、コマンドを実行して、そのコマンドの出力をファイルに出力しようとしています。ファイルでコマンドを取得できますが、このコマンドの結果は取得できません。コンソールにも出力が表示されないため、実行されると想定しましたが、よくわかりません。誰にもアイデアはありますか?
public final static void main(String[] args) throws IOException, InterruptedException
{
FileOutputStream fout = null;
try
{
fout = new FileOutputStream ("spyfile.log");
}
catch (IOException e)
{
System.err.println(
"Exception while opening the spy file: "
+ e.getMessage());
}
TelnetClient telnet;
telnet = new TelnetClient();
try
{
telnet.connect("myserver", 23);
}
catch (IOException e)
{
e.printStackTrace();
System.exit(1);
}
telnet.registerSpyStream(fout);
PrintStream out = new PrintStream( telnet.getOutputStream() );
out.println( "mycommand" );
try
{
telnet.disconnect();
}
catch (IOException e)
{
e.printStackTrace();
System.exit(1);
}
fout.close();
System.exit(0);
}