Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Connecting to other computer in LAN via PERL

by Muskovitz (Scribe)
on Mar 11, 2015 at 12:01 UTC ( [id://1119605]=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks, I want to ask if perl can connect and transfer/send any files in LAN or let's say on internet cafe i tried to use the Net::FTP module but there's no FTP server. Thanks in advance!
  • Comment on Connecting to other computer in LAN via PERL

Replies are listed 'Best First'.
Re: Connecting to other computer in LAN via PERL
by AppleFritter (Vicar) on Mar 11, 2015 at 12:07 UTC

    You will need some server-side support for that -- without a server running on the computer you want to connect to that accepts file transfers, you're out of luck.

    If there's an SSH server running, you may be able to use scp or SFTP; take a look at Net::SCP and Net::SFTP.

      Hi AppleFritter, Yes you're correct first i use IO::Socket to create a server to other computer like a trojan and then i create a client to connect to the server. But i want to build a perl script that can connect to other computers in LAN & transfer/send any files and i think you're right this is out of luck. The only ports are open is 23,80,139 ....
Re: Connecting to other computer in LAN via PERL
by hdb (Monsignor) on Mar 11, 2015 at 12:11 UTC

    You need to be more specific about what you want to achieve. It takes very different technologies to exchange files with a friend versus stealing passwords from a stranger, say.

Re: Connecting to other computer in LAN via PERL
by MidLifeXis (Monsignor) on Mar 11, 2015 at 12:40 UTC

    Is it safe to assume that you have appropriate permissions to access the other computers on the LAN?

    --MidLifeXis

      Hi MidLifeXis, Yes i have permissions to access other computers in LAN, And i just want to know the tricks on how to send files on the LAN via perl.

        This is a client/server setup. Your machine is a client, the server software for that client needs to be available on the remote side:

        • ftp -> ftpd
        • scp -> sshd
        • uuencode + telnet -> telnetd + uudecode
        • cp/copy -> smbd or other CIFS server
        • stick drive -> a pair of sneakers and an available USB port
        • ...
        If you need to install software on the remote machines and they are windows machines and you have the appropriate authorization on the remote machines, you can push a windows installation package to that machine.

        You need to have something on the remote side to talk to. The type of access (permissions + protocol) you have on the remote side will determine how you are able to transfer the files to the remote machine. Some of them can be driven by Perl, others cannot.

        --MidLifeXis

Re: Connecting to other computer in LAN via PERL
by Corion (Patriarch) on Mar 11, 2015 at 12:38 UTC

    Have you looked at system?

    system("copy $local_file \\\\$remote_machine\\C\$\\$target_file");

    This likely requires that you are Administrator on both machines or have the applicable permissions, but the network administrator should easily give those to your user account.

Re: Connecting to other computer in LAN via PERL
by salva (Canon) on Mar 11, 2015 at 13:10 UTC
    Which operating system runs on the machine you are trying to reach?

    Typically, if that is Windows, you just have to share some drawer there and mount it on your local machine.

    If it is some kind of Unix, then probably the easiest option is to install and run a SSH server there and use some SSH/SCP/SFTP/rsync Perl module to access it.

      Thanks Corion,MidLifeXis,salva for replying to this thread, I'll just install a ProFTPD software in every computer here. And start building a Perl script for quick and easy transferring files and monitoring the FTP server. Thanks again!
        Then, ensure you have SSL enabled on the servers and that you are using a FTPS client (module). Otherwise anybody on the same LAN would be able to see your data and capture your passwords.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1119605]
Approved by AppleFritter
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-16 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found