$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 send
ing 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?
Sorry if my advice was wrong.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||