I have a script to read remote file. The script goes as follows,


$remote= '\\\remotehost\remotedir\remotefile.jml';
open(fp, $remote) or die ("could not open the file");

print while(<fp>);


This script runs fine on my windows machine. But the same script when
I run in UNIX, after changing the shebang line to /usr/bin/perl , I

could not open the file file_name.pl at 4

The remote host from which I am trying to read the file is also
Windows box.

1. where am i making wrong?
2. Why the script is not running on UNIX?

Thank you,

10 Years
Discussion Span
Last Post by masijade

Because the path used will not function on a unix machine. The backslants will not work as a path on a unix machine and the double backslant at the beginning of the path also means absolutely nothing to a unix machine.

To access a windows file from a unix machine in this manner (or at least something close to it) will require the installation of a service to allow it (the most popular is samba), and then the script will first have to use this software to connect to the server and then view the file using it.

You would be well served (if you truly wish to do continue in this direction) in downloading samba and then researching samba until you are able to use it, then attempt to incorporate that into your script. (I believe there is a samba module on CPAN and that it might be possible to use it without having to install samba itself)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.