Linux Terminal control

This is a discussion on Linux Terminal control within the Linux Programming forums, part of the Platform Specific Boards category; Hello,
probably somebody can help me how control Terminal in Linux.
I don't know what will be best to create ...

Linux Terminal control

Hello,

probably somebody can help me how control Terminal in Linux.

I don't know what will be best to create to control Terminal(Localhost, SSH). Is possible via Socket launch Terminal and control commands and output? Idea is to connect to terminal and perform some commands take output...to log file and exit? Do you have any Idea what will be a best solution? Thank you,

I'm sorry, but I just cannot understand what you wish to accomplish. I cannot tell whether you refer to

Terminal
a generic name for a number of different applications (x-terminal-emulator, xterm, xfce4-terminal, etc.) that all provide a command-line terminal in most Linux distributions)

Terminal control
via termios interfaces

Terminal libraries
or text-based user interfaces like curses

Creating pseudoterminals
like e.g. screen and expect commands do: they create a pseudo-terminal, and run some other program in that pseudo-terminal. The other program thinks it's being run by the user in a terminal, but both input and output is under full control of your own program.

Connecting to localhost or remote machines via SSH programmatically
so that your own program or script is a stand-in for the user supplying the keypresses to the remote machine

Via the ssh command-line client (external program)

Via an ssh library

Via writing your own ssh client

My instincts do say that your root problem is related to how SSH requires a password. Using a program or a script (or expect) to supply that password is always the wrong path: you should use public keys instead! See here, here, here, or here for guides. If your server does not allow public key authentication, switch to a better server, or complain to your server administrator's boss. If you need noninteractive SSH connections, public keys, fully certificate-based authentication (which is a bit more complicated to set up), and certain even more complex schemes involving Kerberos etc., are the only sane options.

Although all of this looks daunting, it really is not. The above is so massive only because you have a LOT of options to choose from.

In my case, I do a lot of stuff remotely via scripts and commands (having set up SSH keys first). For example, to create a compressed tar ball of /var/www/ on the remote computer, and store the result locally, I can run

Code:

ssh remote.machine tar -cJOC /var/www/ . > remote-www.tar.xz

Or, if the connection is fast and I wish to only gather but not compress the files on that remote machine, I can use