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

Dear Monks,

I've the following situation for which I would like to find the best approach/solution. So all suggestions/advices are very appreciated!!
OK here is the situation: Let's say I've 2 computers, C1 and C2. The first problem I see is that I have a perl script on C1 that needs to execute a script on C2. The second problem is that this script on C2 creates a file, which this script on C1 needs.
Thats the basic idea, I hope it makes sense!!

I've looked around and the following modules looked interesting to me: Net::SSH::Perl and NET::SFTP
Is this really what I should use ?

Thanks a lot
Luca
  • Comment on Complex situation: communication between to PCs

Replies are listed 'Best First'.
Re: Complex situation: communication between to PCs
by zentara (Cardinal) on Mar 25, 2006 at 17:47 UTC
    You are asking a very general question, and you need to decide some things. Do you need encryption? You do if it's going over the internet. You can use Net::SSH::Perl and Net::SFTP in some tandem, but I think it would be cleaner to make your own sockets script with something like Net::EasyTCP. That module supports encryption, works on windows and linux, has port passwords and login capabilities. You could open the connection by starting the server on 1 computer, then connecting from the other machine. Within the same connection, you can send hashes back and forth(which can include files), then run commands.

    I'm not going to write it for you, but you could easily modify Sockets-File-Upload with Net::EasyTCP to do what you want.


    I'm not really a human, but I play one on earth. flash japh
Re: Complex situation: communication between to PCs
by graff (Chancellor) on Mar 25, 2006 at 23:41 UTC
    If there were a way for the command being run on C2 to write its output to STDOUT, instead of creating a file on C2, then Net::SSH would be the only thing you need.

    Net::SFTP will not work unless C2 is running an sftp server. In any case, I think that using Net::SCP from C1 will be more suitable, assuming you know the path and name of the file on C2 that you need to transfer to C1.