AnjuShan has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am using active perl v5.10.1 in win 2008 OS. I shared a directory in Linux PC using nfs share facility and trying to mount/net use that in Win 2008.

If I use 'net use' command from command line it is working perfectly. The same command if I execute it from a perl script,
it gives error as "Network Path not found". I tried to use backquotes, qx etc... But nothing worked out.

I tried to use 'mount' command which is newly available in win 2008. It works fine in command line but not from perl script.
The mount.exe is present in System32 dir and that path is present in environmental variable also. I even tried to give full path.
I am getting the error "'C:\Windows\System32\mount.exe' is not recognized as an internal or external command". This seems strange for me.

Won't that new features in Win 2008 work in Active perl? Or am I missing something here?

Your help is very much appreciated.

my $cmd = "net use Q: 137.201.176.204:/share"; #my $cmd = "net use Q: \\\\137.201.176.204\\share" system($cmd); $cmd = "C:\\Windows\\System32\\mount.exe -u:root -p:root123 \\\\137.20 +1.176.204\\share Y:" system($cmd);

Replies are listed 'Best First'.
Re: system() in Windows 2008
by ikegami (Patriarch) on Jun 08, 2010 at 23:13 UTC
    my $cmd = "net use Q: \\\\137.201.176.204\\share" system($cmd);

    is correct. You might be running afoul some of the security features in newer version of Windows. I know that 5.12 alleviates some of those problems. Perhaps you should try with that version if noone provides a better answer.

Re: system() in Windows 2008
by Argel (Prior) on Jun 09, 2010 at 00:46 UTC
    Are you running your Perl script from within the same cmd.exe that you are running the commands in? Or are you doing something different such as double-clicking on an icon (or even just running it in a different cmd.exe)? If you are doing something different, then are you running the cmd.exe that it works in as adminsitrator or with some other form of elevated permissions? Have you checked the Event Logs? You might also want to turn security auditing on to see if anything shows up in the security Event Logs.

    Elda Taluta; Sarks Sark; Ark Arks

      Yes, I am using the same cmd.exe and it is running in administrative mode only. And I suspected the security settings and for testing I disabled firewall settings in order to allow nfs mount. I didnt check the event logs. Will check it.
        I think ikegami and I were both thinking more of local security policies (e.g. maybe perl.exe is being restricted in some way). If it was the firewall then wouldn't they wither both work or both fail?

        Elda Taluta; Sarks Sark; Ark Arks

Re: system() in Windows 2008
by Anonymous Monk on Jun 08, 2010 at 23:12 UTC
    add
    print "COMPARE THIS >>> $cmd <<<<\n";
    and then compare $cmd to what you have in your shell
Re: system() in Windows 2008
by wwe (Friar) on Jun 09, 2010 at 17:20 UTC
    try to use
    cmd /K "net use..."
    this will create a new cmd process and execute the following command. Maybe there is some "magic" implemented in the cmd or the net command is now a built-it of the cmd.