ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
There can a quite a few possibilities of doing this. I can name a few
1. client-server model where your program has a server which on receiving a mesg from the client program executes a comand on the remote system.
2. Your client end programs can also embed some telnet/rlogin/rsh or ssh client side functionality. Just minimal functionality to just able to logon to remote peer and execute some commond. I have seen a few IDEs doing something like this for remote make, etc.
I'd like to know what other alternatives are possible !!!
you can get the perl mod for ssh, then set up a key on the remote server and do ssh commands (which are secure). for less secure alternatives there are the old "R" commands.
these can all be easily incorporated into a perl script.
Manas: Your option 1 looks good. But it's difficult to install / run constantly a server on the remote box. My client program will not always run (once a month, may be).
Option 2: how can i embed some ssh client on client side?
Tyler: Good idea. WIll try to do it. However, the program needs to be in C/C++. On top of it, I don't know perl yet.
I figured out what I believe can be a solution. I can use sockets to connect to the telnet deamon running on remote, log in, and be able to execute commands. I will give it a try.
Originally posted by concoran
I figured out what I believe can be a solution. I can use sockets to connect to the telnet deamon running on remote, log in, and be able to execute commands. I will give it a try.
Ravi,
This is exactly the solution #2 i proposed. However just opening a tcp connection to the port 23 on the remote side may not be sufficient to execute the commands. You'll have to implement a small subset of the telnet client's functionality in you application.
However like Tyler said ssh is a more secure solution.
"ssh remotehost command" will execute any "command". Try "ssh remotehost ls -al /" this would do "ls -al /" on "remotehost".
Any commands that follow the "host" after the ssh command is considered by ssh to be the command to execute on the remote computer. This is because SSH is designed to be a drop-in replacement to rlogin and rsh.
Now how do to do this non-interactively? ie. You want to run a remote backup script on a remote host from a cron job on your desktop, for example without the script being asked a login password. Well, you have to configure public key authentication on your remote host and give the public key of the user that you will be using to to connect to the remote host, and add that key the the remote host's list of keys to allow entry. This is a very simple process check the OpenSSH manpages or do search on google.
Here's another option for yet another use: You can use
the Expect language to write a script that logs in to reme sites no matter what they are running (even IBM)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.