Re: [Forum] Scrpt til indlokning på stofanet

From: Esben Nielsen <simlo@phys.au.dk>
Date: Thu Jun 13 2002 - 15:58:51 CEST

#! /usr/bin/perl -w
chmod# A script to get stofa connection up
# Also, a test to do sockets in perl

require 5.002;
use strict;
use Socket;

my $ID = "????\n" ;
my $pwd = "???\n" ;

my $cmd = 1; # command to get the net up
if ( $ARGV[0] ne "" ) { $cmd=2; } # or the one to get it down

my $host="192.168.30.2";
my $serviceport = "259";

my $iaddr = gethostbyname('localhost');
my $proto = getprotobyname('tcp');
my $paddr = sockaddr_in(0,$iaddr);

$|=1;

my $hisiaddr = inet_aton( $host ) || die "unknwon host";
my $hispaddr = sockaddr_in($serviceport,$hisiaddr);

socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect (SOCKET, $hispaddr ) || die "connect: $!";

my $line = "-" x 128;
my $ch = " ";
while ($ch ne ":" ) {
  read(SOCKET, $ch, 1);
  print $ch;
}
print "\n";

my $count = send(SOCKET,$ID,0);
print "Sent ID (c=$count)\n";

$ch = " ";
while ($ch ne ":" ) {
  read(SOCKET, $ch, 1);
  print $ch;
}
print "\n";

my $count = send(SOCKET,$pwd,0);
print "Sent pwd (c=$count)\n";

$ch = " ";
while ($ch ne ":" ) {
  read(SOCKET, $ch, 1);
  print $ch;
}
print "\n";

$ch = " ";
while ($ch ne ":" ) {
  read(SOCKET, $ch, 1);
  print $ch;
}
print "\n";

my $choice = "$cmd \n" ; # 1=connection up
$count = send(SOCKET,$choice,0);
print "Sent choice: $cmd (c=$count)\n";

$ch = " ";
while ($ch ne "." ) {
  read(SOCKET, $ch, 1);
  print $ch;
}
while ($ch ne "\n" ) {
  read(SOCKET, $ch, 1);
  print $ch;
}
print "\n";

close SOCKET or die "couldn't close cocket: $!";

Esben
On Thu, 13 Jun 2002, Svend Erik Venstrup wrote:

> Hej
>
> Kasper Hald
>
> Viste i en tidligere mail et script som loggede ind og ud fra stofanet.
>
> Måske kunde Kasper lokkes til at sende det igen?
>
> --
> Hilsen svend
> (-;>/
>
>
>
>
>
> --
> AaLUG Forum liste - Forum@aalug.dk
> http://www.aalug.dk/mailman/listinfo/forum
>
Received on Thu Jun 13 15:58:51 2002

This archive was generated by hypermail 2.1.8 : Tue Jul 19 2005 - 16:03:50 CEST