You're right!

It appears that I'd been considering "net use" to be a command, when it
appears that "net" is the command and "use" is a modifer.

I haven't been able to double check it yet here at home, but when I
modify the test program to invoke only "net use", I get the expected
report, and the test program ends gracefully.

Thanks again, and a Merry St. Patrick's weekend to you all!

F.

************************************************************************
Francoys Crepeau
Ottawa, Ontario, Canada
mailto:[EMAIL PROTECTED] 

-----Original Message-----
From: John W. Krahn [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, March 16, 2002 00:49
To: [EMAIL PROTECTED]
Subject: Re: Problems running Win32's "net use" with system()


Francoys Crepeau wrote:
> 
> Hi everyone! I hope someone can tell me what I'm doing wrong.

Hello, I hope so too.

> I'm running ActivePerl 5.6 on an NT4 (service pack 5) box.
> 
> One of the things I have to do is to have a Perl script "map" a 
> network drive to a drive letter.
> 
> When one manually does this from the command line, it is done using 
> the "net use" command, specifying as parameters the destination drive 
> letter (or a wildcard to get the first available one) and the network 
> drive.
> 
> I'm trying to do this by calling system() from my Perl script, but the

> call to system() fails. However, if I type the same command at the 
> command line, it works.
> 
> I thought at first that I might not be correctly invoking the system()

> function, but I am able to use it to have the "dir" command executed.
> 
> Shown below is the source of my test program:
> 
> #***** START OF TEST PROGRAM
> use strict;
> use warnings;
> use diagnostics;
> 
> # For unbuffered I/O.
> $| = 1;
> 
> # Set up the arguments for the calls to system().
> my( @sysargs0 ) = ( 'dir', '..' );
> my( @sysargs1 ) = ( 'net use', '*',  '\\\\rndnt55\\rndapps' );
                       ^^^ ^^^
The problem _could be_ that you have two parameters in the first
element.  Try it with system( 'net', 'use', '*', '\\\\rndnt55\\rndapps'
); and system( 'net use * \\\\rndnt55\\rndapps' );


> # Just do a call to the Win32's "dir .." command.
> # Works OK.
> system( @sysargs0 ) == 0
>   or die( "system( \@sysargs0 ) failed: $?" );
> 
> # For verification, see what system() is receiving.
> for( my $i = 0; $i <= $#sysargs1; $i++ ) {
>   print( "\t\$sysargs1[ $i ] = $sysargs1[ $i ]\n" );
> }
> 
> # This call to Win32's "net use" fails. !?!?!
> if( system( @sysargs1 ) != 0 ) {
>   my( $exitValue ) = $? >> 8;
>   my( $signalNum ) = $? & 127;
>   my( $dumpedCore ) = $? & 128;
> 
>   print( "\t\$exitValue = $exitValue\n" );
>   print( "\t\$signalNum = $signalNum\n" );
>   print( "\t\$dumpedCore = $dumpedCore\n" );
> 
>   die( "system( \@sysargs1 ) call failed: $?" );
> }
> #***** END OF TEST PROGRAM


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to