in reply to socket programming
$cmd = 'qx(ls)'The server does not eval this string, so you'll have to remove the "qx()" from the string. When you do this, server will receive the string "ls" and will run system("ls") which is probably what you want.
print "$destination ,$cmd \n";You don't actually send anything to the server. Try sending your string or use IO::Socket::INET and print $socket $your_data.
By the way, you may want to set the server-site socket to the non-blocking mode (for example), because right now you are trying to receive MAX_RECV_LEN (=65535) bytes while the client sends only two ("ls"). I'm not sure, but recv will probably block until it receives LENGTH data or the socket is closed (which is unlikely with UDP).
And another thing: shouldn't it be better to run some already existing remote shell server? For example, using ssh you'll be able to encrypt your connection, protect your password and restrict the shell access, not leaving it open to any person with a netcat or similar program.
Did I forget to mention that ssh is scriptable via Perl?
|
---|