I can write a small perl script communicating to this application connecting to tcp port 7000 etc etc. But I am trying to do something different now.
I may have misunderstood almost everything, but my approach was to hook inte the app's STDIN/STDOUT assuming those are the handles to hook. Let me illustrate with some code.
/L#!/usr/local/bin/perl use strict; use warnings; use IPC::Open2; use IO::Handle; $/ = "\r"; my $CR = "\r"; my $NL = "\n"; my @msg = ('INIT', 'STATUS', 'QUIT' ); my ($reader, $writer) = (IO::Handle->new, IO::Handle->new); my @program_and_arguments = ('/usr/local/script/netdiag'); eval { open2($reader, $writer, @program_and_arguments); }; if ($@) { if ($@ =~ /^open2/) { warn "open2 failed: $!\n$@\n"; return; } die; } select $writer; $|++; select STDERR; $|++; select STDOUT; $|++; print STDERR "Here 1\n"; my $req = shift @msg; print $writer $req, $CR; print STDERR "Here 2\n"; # We come here, than it han +gs my $answer = <$reader>; die "1" unless $answer; print STDERR "SVR:$answer$NL"; [... keep up the dialog...] print STDOUT "Done$NL"; __END__
In reply to Re^2: Networking without a network
by Anonymous Monk
in thread Networking without a network
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |