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


Hi,
how do i set a path for CSV file?

Replies are listed 'Best First'.
Re: How to Set new file path for CSV file
by merlponk (Scribe) on Sep 22, 2009 at 08:43 UTC
    Since your webserver is a remote computer, access to it is not possible, unless there are special ways to access this remote computer. This could either be via FTP, SSH (e.g. SFTP or SCP), SMB (aka "Windows Network") or even HTTP (where a special "file receive" has to be implemented), to name a few; all different protocols that enable two computers to communicate over the network. Without a special protocol to enable remote communication, file copying is not possible (if I understood you correctly).

    So it's not that easily answered in a few sentences and some knowledge about communicating over the network on your part is essential.
Re: How to Set new file path for CSV file
by tilly (Archbishop) on Sep 22, 2009 at 15:49 UTC
    Let me see if I have this right. You're running your script on a desktop machine. You want it saved on a remote machine. You're not getting it saved there.

    First tip. Follow the suggestions in perlstyle and have warnings on your open. Many things can go wrong, and the error messages will help you figure out which.

    Secondly to solve your problem you need to have a way to directly access the filesystem. At a guess from the path you tried, the client is a Windows machine. In that case try to locate the network share then proper full path and open that directly. (Note, you need the path as it looks from the client machine, not as it looks from the webserver.) Be aware that you have to switch \ to /, or else double your \ in your strings.

    There are many reasons why that might fail, including permissions on the webserver. In that case you need to talk with a sysadmin and get some other networking solution set up. One is to have an ftp server. Another is that if this is for a local workgroup, you could put the file in a shared directory (using the appropriate smb path) and then have a file:/// URL in the webserver. Another is to have a CGI program on the webserver that can accept a file upload and write it directly to the webserver.

    Good luck. Often the solution to this kind of problem tends to be fairly simple, but finding the missing piece of information that makes it simple (eg the right way to name the remote directory) can be very frustrating...

Re: How to Set new file path for CSV file
by ELISHEVA (Prior) on Sep 22, 2009 at 07:28 UTC
    I tried giving the drive name of the server in the file path but it doesn't work.

    What code did you use to "give it"? And to what exactly did you "give it"? the server? the browser? an HTTP request? What happened when it didn't work? Did your script crash burn and die? Did you just sit there waiting for nothing to happen? Did you get an error message? A warning? What did it say?

    Best, beth