If you cannot install any "foreign" tools on your system, then sending data to Magma may be a challenge. But if you have access to either Perl, BASH or telnet on the system then it is possible.
Perl version:
Code: Select all
#!/usr/bin/perl
#
sub sendToMagma {
use IO::Socket;
my($server,$port,$msg) = @_ ;
my $response;
my $sock = new IO::Socket::INET (
PeerAddr => $server,
PeerPort => $port,
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;
print $sock $msg;
shutdown($sock, 1);
while ($response=<$sock>)
{
print "$response";
}
close($sock);
}
$host = $ARGV[0];
if ($#ARGV != 2) {
$port = 1984;
$msg = $ARGV[1];
}
else {
$port = $ARGV[1];
$msg = $ARGV[2];
}
sendToMagma($host, $port, $msg);
Code: Select all
#!/bin/bash
#
HOST="$1" ; shift
if test $# -gt 1; then
PORT="$1"
shift
else
PORT="1984"
fi
MSG="$1"
exec 3<>/dev/tcp/$HOST/$PORT || exit 1
echo "$MSG" >&3
exit 0
Bourne / Korn shell (requires telnet):
Code: Select all
#!/bin/sh
#
HOST="$1" ; shift
if test $# -gt 1; then
PORT="$1"
shift
else
PORT="1984"
fi
MSG="$1"
( echo "$MSG"; sleep 1 ) | telnet $HOST $PORT 2>&1 >/dev/null | grep -v "closed by foreign host"