Hello ;-)

I tried to connect to the amindexd service via Java. It is possible
to read what the Server first barfs out... but if I try to send
some commands (SECURITY root, HOST localhost, etc.) nothing happens
and the debug output of amindexd says, that there is an unexpected EOF
and some unprocessed input (the mentioned commands I sent before).

=========================================================================
This is what the /tmp/amanda/amindexd.debug says:

< 220 kant AMANDA index server (2.4.1p1) ready.
? unexpected EOF
? unprocessed input:
-----
? SECURITY root

-----
amindexd: pid 5867 finish time Thu Feb 15 17:27:19 2001

=========================================================================

I also tried to get a connection via Telnet, but the socket-port
of the telnet process is always to high, to be taken as a secure port
by the amindexd. Do you know a possibility of setting a portrange
to a telnet process?


Well, please have a look at the following (attached) tiny java program
and give me some hints, how to get a connection to the amindexd.



I want to write some interface from Java to amindexd for providing
a possibility for writing native java programs to take use of
the Amanda Backup Service ;-)


Please sent me a copy (CC:) to my private account ( mailto:[EMAIL PROTECTED])

thanx in advance,

Sebastian

import java.net.InetAddress;
import java.net.Socket;
import java.io.InputStream;
import java.io.PrintWriter;

public class testsock {

  public static String read(InputStream in) throws Exception {
    StringBuffer sb = new StringBuffer();

    while (true) {
      String str = "";
      while (in.available() > 0) {
        byte b[] = new byte[in.available()];
        in.read(b);
        str = new String(b);
        sb.append(str);
      }
      if (str.indexOf("AMANDA") > -1)
        break;
      else if (str.indexOf("5") > -1)
        break;
      else if (str.indexOf("2") > -1)
        break;
    }
    return sb.toString();
  }

  public static void main(String args[]) throws Exception {
    Socket s = new Socket("localhost", 10082, InetAddress.getLocalHost(), 1028);
    System.out.println("localport: "+s.getLocalPort());
    InputStream in  = s.getInputStream();
    
    System.out.println("got: "+read(in));

    PrintWriter out = new PrintWriter(s.getOutputStream(), true);
    System.out.println("send: SECURITY root");
    out.println("SECURITY root");

    System.out.println("got: "+read(in));
  }

}

testsock.class

#!/usr/bin/perl

use Net::Telnet();

$hostname = "localhost";

$port = 10082;

$t = new Net::Telnet ( Host => $hostname, Port => $port);
$t->open("$hostname");

do
{
  $data = $t->getline(Timeout => 40);
  print "got: $data";
  $t->print("SECURITY root\n");
} while (true);

Reply via email to