in reply to Re: Copying files using a specific port
in thread Copying files using a specific port

Thanks for the quick response,
I don't wan't to use the other methods suggested such as FTP, mount etc., and would like to use purely perl script(s).

Here's what Im trying to do:
Execute a perl server script on one machine, which listens to all clients from a specific port. Connect to the server using a socket script via the predefined port. NOw, that the connection is established using the socket-server, use the same script to copy files from the client to the server over the same port.
  • Comment on Re: Re: Copying files using a specific port

Replies are listed 'Best First'.
Re: Re: Re: Copying files using a specific port
by skx (Parson) on Oct 06, 2003 at 11:21 UTC

     Well the short answer is "Yes" it is possible to create code which does this.

     I think that most people would question why you would wish to do this though, there are many tools which solve this problem already which have been mentioned above.

     If you have some specific problem with them then you should probably mention it - instead of looking to reinvent the wheel.

     For example you might have a problem with entering passwords - in which case you should investigate the use of shared keys and SSH, making passwords unnecessary.

     Or if you do not have root access to the machine you wish to copy files to, and cannot install or modify software there then that might be a valid vetoing option. However you may be able to do things in reverse in that case, instead of connecting to the machine connect from there and "pull" the files.

     The perl code to do the copying is going to open up a whole can of worms:

    • You will need to create a protocol to specify the password (you are going to password protect this, right?) to allow the copy to proceed.
    • You will have to pass the name of the file you wish the receiving side to write to.
    • You probably want to "lock" the sender into a particular directory, so they don't write to ~/.ssh/authorized_keys, or /etc/password for example.
    • You'll need to deal with errors writing and signal them back to the client.

     Those are just a small list of things that occur to me.

     However if you really want to do this, and it's not exposed to the internet you should start by looking at IO::Socket::INET, File::Copy and related modules.

    Steve
    ---
    steve.org.uk
      Thanks!

      Firstly, the script that Im trying to code is written for Windows using the win-32.

      The reason why I'm trying to do this is because, the machines to which Im trying to copy files to are under the DMZ. I am an admin for that machine, but want to access it remotely using scripts from my local machine.

      I can have only one port open for the purpose, and hence, Im trying to figure out a method.

      FTP and other File Transfer methods are not possible due to restrictions implied by the firewall.
      Thanks again.