Here is a code snippet where I use winscl:

This script performs name lookups. Maybe you could use this and adjust it to
suit your needs.

if ($ARGV[1] =~ /\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}/) {
        $name = 0;
        print "\n Retrieving WINS records IP = $ARGV[1]\n\n";
        open (outfile, ">tmp.txt");
        print outfile "$ARGV[0]\n";
        print outfile "1\n";
        print outfile "$ARGV[1]\n";
        print outfile "0\n";
        print outfile "EX\n";
        close outfile;
        open (A, "winscl N SDB <tmp.txt |");
} else {
        $name = uc($ARGV[1]);
        print "\n Retrieving WINS records NAME = $name\n\n";
        open (outfile, ">tmp.txt");
        print outfile "$ARGV[0]\n";
        print outfile "0\n";
        print outfile "0\n";
        print outfile "$name\n";
        print outfile "1\n";
        print outfile "00\n";
        print outfile "0\n";
        print outfile "0\n";
        print outfile "0\n";
        print outfile "10\n";
        print outfile "4\n";
        print outfile "0\n";
        print outfile "EX\n";
        close outfile;
        open (A, "winscl N GRBN <tmp.txt |");
}
        while (<A>) {
                if ($_ =~ /-----------------------/) {
                        print $_;
                        while (<A>) {
                                if (($_ =~ /Name is /) && ($name)){
                                        if ($_ !~ /\($name\W*\)/) {
                                                close A;
                                                last;
                                        }
                                }
                                print $_;
                                if ($_ =~ /-----------------------/) {
last; }
                        }
                }
        }

unlink "tmp.txt";

-----Original Message-----
From: Scott Higgins -ESC [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 28, 2000 5:23 PM
To: '[EMAIL PROTECTED]'
Subject: Using Perl to remove Wins entries


I'm trying to use Perl to remove an entry from our WINS server using
winscl.exe, a resource kit utility.  Winscl is a dos program that opens a
command window and prompts the user for several entries before removing the
entry from the wins database.  Winscl will not take all the entries it needs
via command line arguments, so I'm stuck with trying to respond to the
prompts via ipc::open2, or open |, or maybe win32::process (I couldn't find
any information on win32::process regarding how to pass information to the
process once the process was created) .  Below is some pseudo code that
shows what I'm trying to do (miserable failures mercifully omitted).

In my tests, I don't see that the "print WRITEME"'s have actually put
responses into the command window.  I've tried \n after the writme's, \cM,
and lastly the ascii code of 013 hoping to get it continue on through the
process.  I even thought about writing something using Win32::API against
winsrpc.dll.  Thankfully, I couldn't find any information on the DLL.

use IPC::Open2;
$pid = open2(*README, *WRITEME, 'winscl.exe'); #Run Wins removal program
print WRITEME "T\013"; #enter T for TCP IP plus an ascii CR
print WRITEME "192.168.x.x \013"; # Enter Wins Server IP Address
print WRITEME "DN\013";
etc, etc, etc.
close (WRITEME);

Thanks in advance,

Scott
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to