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

i had a basic question (i think)! i wish to create a text file on a remote server, and occasionally append to it from local machine. any help would be appreciated.

Replies are listed 'Best First'.
Re: creating and writing a file on server
by Aristotle (Chancellor) on Oct 31, 2002 at 20:05 UTC

    $ ssh remotehost cat '>>' textfile < localfile maybe?

    Or what is it you want to do? There are about a million ways to create a textfile on a remote server - what are your constraints?

    Makeshifts last the longest.

Re: creating and writing a file on server
by BrowserUk (Patriarch) on Oct 31, 2002 at 20:14 UTC

    Any attempt to answer your question would require considerably more information than you have so far provided.

    For example. What OS(s) and filesystem(s) are running on the server and workstation?

    How much and how often is <ioccasionally append?

    Will the occasional be driven by a manual process (ie. someone running a program) or by a scheduled or deamon type long-running process?

    What is (or what is the source of) the data you want to write?

    I'm assuming that you are trying to do this from perl. If so, what have you tried already and what problems did you encounter?

    Showing us your code is always a good way to get people interested in helping.


    Nah! Your thinking of Simon Templar, originally played by Roger Moore and later by Ian Ogilvy
      sorry for the brief question. i tried Aristotle (first reply) solution and i got it to work. the OS is am working is freeBSD.

      ssh remotehost cat >> filename <localfile

      later i append stuff into filename at various times. now the problem is permission as every attempt to write to this file requires a password. and the script needs to be automated.

        See: man ssh
        You will find (mostly) everything about ssh authentication.

        Aristotle++ His internet prescience device must be performing optimally tonight.


        Nah! Your thinking of Simon Templar, originally played by Roger Moore and later by Ian Ogilvy
        You will want to generate a key pair for this purpose. You copy the public key to the remote machine, and use ssh-agent on the local machine to keep the private key authenticated. (Otherwise you will need to enter the key's passphrase to connect.) As fglock said, man ssh will provide you with plenty of information - Googling for ssh tutorial will also reveal a wealth of quickstart help.

        Makeshifts last the longest.