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

What I am trying to accomplish: I want to move files from various network shares to the hosting server.

the hosting server: \\web02
network shares: \\host01\iso, \\host02\iso

When a user clicks a link on the website, it will run a perl script on the hosting server that will copy iso files on the share to the hosting server. my code:
#!/usr/bin/perl -w print "Content-type: text/html\n\n"; $dirname = "\\\\host01\\ISO"; opendir ( DIR, $dirname ) || print "error: $!<br>"; while( ($filename = readdir(DIR))){ print("$filename<br>"); } closedir(DIR);
If I open a web browser on the hosting server and click the link, the script will work and display the contents of the folder, however, when I try it on any other server, it gives the error: No such file or directory. The script works on any server if run from the command line.

Replies are listed 'Best First'.
Re: Hyperlinking to Perl script to access network shares.
by ahmad (Hermit) on Jul 21, 2010 at 15:37 UTC

    Try to map those shares as network drives, then open it using the drive letter.

Re: Hyperlinking to Perl script to access network shares.
by intel (Beadle) on Jul 21, 2010 at 22:22 UTC
    You should definitely use another file transfer method other than Windows shares. installing an SSH server and using Net::SSH:Perl or Net::OpenSSH would be the best way to do it, but if you're looking for quick, insecure and dirty, you should at least use Net::FTP.
Re: Hyperlinking to Perl script to access network shares.
by Sinistral (Monsignor) on Jul 22, 2010 at 18:17 UTC

    When you say "open a web browser on the hosting server and click the link", do you mean that you're using File...Open in the browser to open a local file, or that you actually put the same URL (including hostname) into the browser regardless of which machine you're on?

    If you're using local file access vs. web server access, that could explain some of the issue. It's possible that the Windows user running the web server does not have permissions to access the shares. If you're running command line, then you're running as some user, perhaps Administrator. That's not the same user that IIS (Apache?) is using

    As others have noted, mounting the share as a drive will help some

      The problem was IIS, it was probably using a log in with absolutely no permissions. I switched to Apache and the script works!