Hello,

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

#!C:\Perl\bin\perl.exe

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

print while(<fp>);

close(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
get

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,
Regards,
kath.

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.