#!/usr/bin/perl
require 'config/paths.pl';

$user = $ARGV[0];
$pwd  = $ARGV[1];
$target = $ARGV[2];
die "Usage: perl/rdp.pl <user> <passwd> <host>\n" if(! $target);
die "bin/rdesktop not found\n" if(! $RDESKTOP);
if (fork() == 0) {
  $err0  = `$RDESKTOP -u $user -p $pwd -g 10x10 -C -X $target 2>&1`;
  if ($? == 13) {
    print "Login successful ($?)\n";
  } else {
    print "Login unsuccessful ($?)\n";
  }
} else {
sleep(1);
$err1  = `$RDESKTOP -u $user -p $pwd -g 10x10 -C -X $target 2>&1`;
exit;
}
