Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Cannot acces a remote file

by Roger (Parson)
on Aug 22, 2005 at 05:56 UTC ( #485617=note: print w/replies, xml ) Need Help??

in reply to Cannot acces a remote file

Your URL for the remote file is wrong in several places.

1. Backslashs inside the string. The backslash will escape the next character. You will need two backslashes to represent a single backslash.
eg. "\\\\172.x.x.x\\foo\\bar"

2. How the "D:" drive is exported from the other machine. I would think that something like
would be more appropriate.

But I am not an expert in Windows, so you could be right in 2, but 1 is definitely wrong.

Replies are listed 'Best First'.
Re^2: Cannot acces a remote file
by ikegami (Patriarch) on Aug 22, 2005 at 14:39 UTC
    Actually, using "D$" should work, even without creating a share. Windows provides a "secret" share for every drive where the name of the share is the drive letter followed by a dollar sign. These shares are possibly only available to admins.
    $path = '\\\\172.x.x.x\\D$\\foo\\bar\\filename';

    Update: Fixed the problem davidrw pointed out.

      the dollar sign needs escaping, too:
      $path = "\\\\172.x.x.x\\D\$\\foo\\bar\\filename";
Re^2: Cannot acces a remote file
by chennaiite (Sexton) on Aug 22, 2005 at 06:09 UTC
    Thanks Roger.... I tried both...but no result...

    It throws cannot open the remote file invalid argument....

    Is there anyother way to access the remote file.....

    Just I want to copy the remote file to local and then make changes,Finally save new updated file in remote place...


      open cannot authenticate to the server for you.

      1. Make the changes roger has mentioned (i guess you have done that already)

      2. Now go to start->RUN and then type \\IP_ADDRESS (corresponding to your server)

      3. It will ask you to authenticate, type login and password

      4. Now try you perl script again

      I tried to access the files from one of my computers on my network and i get Invalid argument at -e line 1.

      Ignore the -e part as i was using command line perl. After I authenticated with the machine like the way i just explained i was able to access the file

      Hope this helps. I am not sure how windows's fileserver works with authentication and hence don't know ways to automate it.

      On the other hand you can also map your network server to a drive and try to see if that works better for you?

      update: if you don't know what path to use, just start->run type the ip_address\ and then browse to the directories. In windows explorer if you have turned on "address" bar then you can copy that into your open call. Just make sure you escpate \ with \\



      It seems you first have to mount a share on the other server... try Win32::NetResource from CPAN, that does a good job

      If you want to find out what to do, try the dosbox command

      net use z: \\\D$ /user:administrator secret

      (if secret is the password). If you type \\ in your windows explorer and you see the share (e.g. with the name d), then use something like

      net use z: \\\D /user:me secret

      (net help use gives you more information about this)

      If that works fine, you've got enough information to mount it with Win32::NetResource

      Best regards,
      perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8."

        It seems you first have to mount a share on the other server.
        Perl's open can handle UNC paths, but that's true if you need to login as someone different than on the current machine
      How is the remote drive exported in the first place? Can you browse it at all? Why don't you open the explorer session, and manually browse to the location of the file under the NETWORK NEIGHBOURHOOD, and grab the fullpath name in the address bar. Then apply the double backslash bits to make it work?

      Does the remote machine have an FTP server (and this file available through it)? If so, this task would be very easy with Net::FTP. But if not, as Roger says you need to determine how the file is shared by windows.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://485617]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2022-12-03 22:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found