If you don't want to use the substr command, you could simply remove
all leading backslashes as follows:
$computer =~ s|^\\*||;
Just my $.02,
--Chuck
--- "Bellenger, Bruno (Paris)" <[EMAIL PROTECTED]> wrote:
>
> And this will list all files open through the network on a server.
> Syntax is :
>
> Perl scriptname.pl computername
> or
> Perl scriptname.pl \\computername
>
>
>
> # NetFileEnum($server, $basepath, $user, \@info)
> # Supplies information about some or all open files on server
> \\$computer.
> # Specify target computer as argument to the script
> # (with or without preceding '\\')
> use Win32::Lanman ;
>
> $computer = "$ARGV[0]" ;
>
> $computer = substr($computer,2,) if (substr($computer,0,2) eq "\\\\")
> ;
> print "\n------------------[Open files on :
> $computer]-----------------\n\n"
> ;
>
> if(!Win32::Lanman::NetFileEnum("\\\\$computer", '','', \@infos)) {
> print "Sorry, something went wrong; error: ";
> # get the error code
> print Win32::Lanman::GetLastError();
> print " : $^E" ;
> exit 1;
> }
>
> foreach $info (@infos) {
> @keys = keys(%$info);
>
> ## Enable the following lines to display more details :
> # foreach $key(@keys) {
> # print "$key: ${$info}{$key}\t";
> # }
> # print "\n" ;
>
> push @files,"${$info}{username} \t ${$info}{pathname}" ;
>
> }
>
> for ($i=0; $i<=$#files ; $i++) {print $i+1, "\t", $files[$i], "\n" }
> print "\n";
>
>
>
>
> _____________________________________________
> Bruno Bellenger
> Sr. Network/Systems Administrator
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: mercredi 14 mars 2001 12:02
> To: [EMAIL PROTECTED]
> Subject: Finding Logged in users
>
> Hi,
>
> I have today seen reference to and have installed the lanman module.
>
> I cant find any documentation for it.
>
> I would like to use it to find the logged in users to our
> development
> server at http://xxx.xxx.xxx
>
> I am using NT and are connected to it via our own intranet.
>
> I have tried the following code but it gives an error 123
>
> # NetWkstaUserEnum($server, \@info)
> # Lists information about all users currently logged on \\$computer.
> # Specify target machine as argument (with or without preceding \\)
>
> #==============================================
> # SPECIFY TARGET COMPUTER AS FIRST ARGUMENT;
> #==============================================
> use Win32::Lanman ;
>
> #$computer = "$ARGV[0]" ;
> $computer = '//rwaldock' ;
>
> print "\n" ;
>
> $computer = substr($computer,2,) if (substr($computer,0,2) eq
> "\\\\") ;
> print "------------[Listing logged in users on
> $computer]------------\n" ;
>
> if(!Win32::Lanman::NetWkstaUserEnum("\\\\$computer", \@info)) {
> print "Sorry, something went wrong; error: ";
> # get the error code
> print Win32::Lanman::GetLastError();
> print " : $^E\n" ;
> exit 1;
> }
>
> foreach $user (@info) { @keys = keys %$user;
> foreach $key (@keys)
> {
> ${$user}{$key} =~ s/^a-//i ;
> print "$key=[${$user}{$key}]\t";
> $mail_alias = ${$user}{username} ;
> }
>
> print "\n\n" ;
> }
>
> I am very new to this module and have almost no idea what it does or
> how it does it and would appreciate any help.
>
> I have full access to the web server via pc-anywhere and so I can do
> anything to it.
>
> I am using to try to find out what students are logged in to it and
> using Frontpage.
>
> Thanks
> Roy
>
> _______________________________________________
> 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
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin