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

Does anyone know the best approach to do this? I've looked at the File-Remote module but didn't have any luck. I guess I could telnet and do it that way unless someone has a better suggestion.

Thanks

Replies are listed 'Best First'.
Re: Read/Write to Unix Files from Windows?
by jettero (Monsignor) on Jan 23, 2007 at 19:45 UTC

    I believe this can be done over samba using open, ftp using Net::FTP, ssh Net::SSH, or even telnet Net::Telnet — and all from perl. Did you have a preference? I think "best" is probably a subjective evaluation which depends on the tasks and environments at hand.

    UPDATE: File::Remote looks pretty slick to me. I might even try to use it later today. Is there any particular reason it won't work? It appears to use rsh/ssh as instructed and might be a pretty clean way to do it.

    -Paul

      not really, maybe ssh or telnet
        It might be the way I'm using it...it never seems to find the file I'm working with. Not sure why
Re: Read/Write to Unix Files from Windows?
by Zaxo (Archbishop) on Jan 23, 2007 at 19:54 UTC

    It's pretty easy to write unix format text files on your windows machine,

    { local $\ = chr 10; # . . . }
    among many ways.

    If the problem is to write your file directly to the unix box, the answer depends on the kind of access you have. I'd recommend ssh over telnet, and sftp is nice. NFS is possible, but less desirable IMO. sftp will translate line endings for you in ASCII mode.

    After Compline,
    Zaxo

Re: Read/Write to Unix Files from Windows?
by Joost (Canon) on Jan 23, 2007 at 23:06 UTC
    There's no such thing as "unix files" unix files are just streams of bytes, just like on most other operating systems (like windows).

    The biggest difference is that windows distinguishes between text and binary files (it interprets the line-ending character differently for text files) while unix doesn't. See binmode and perlport.

    If you want to read and write files from/to a unix machine, you can use all kinds of network protocols to send/recieve the files. Personally, I prefer to use plain scp to transfer files, since it's available everywhere, has good authentication mechanisms and is encrypted. There are also perl modules to do scp, but they tend to require a bit more work setting up, especially on windows. See for example putty for nice and free ssh & scp clients for windows.