Thread: Linux Terminal control

  1. #1
    Registered User kaspari22's Avatar
    Join Date
    Jul 2008
    Czech Republic, Doubravice

    Linux Terminal control


    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 log file and exit? Do you have any Idea what will be a best solution? Thank you,

  2. #2
    Ticked and off
    Join Date
    Oct 2011
    La-la land
    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
      1. Via the ssh command-line client (external program)
      2. Via an ssh library
      3. 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.

    Some recommended reading:
    • Pseudoterminals(Wikipedia)
    • man 7 pty, Linux pseudoterminal interfaces
    • man 1 ssh, the man page of the OpenSSH command-line client (if you want to just have your own program or script replace the user)
    • libssh tutorial; in case you want to create your own SSH client

    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
    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
    ssh remote.machine tar -cOC /var/www/ . | xz -z -F xz - > remote-www.tar.xz
    Or, if I just want the file listing in a shell variable, I can use
    WWWFILES="$(ssh remote.machine find /var/www -ls)"
    Or, if the server has ample CPU power, but the connection is slow, I can save bandwidth by compressing the list on the remote machine and decompress on the local machine using
    WWWFILES="$(ssh remote.machine 'find /var/www -ls | xz -z -F xz -' | xz -d -F xz -)"
    If you have a specific task, and preferred language (shell script, Python, C), I should be able to help you choose a straightforward way to solve your actual problem?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. linux socket TCP control
    By learner71 in forum Linux Programming
    Replies: 2
    Last Post: 05-23-2013, 09:25 AM
  2. Flashing Text in Linux Terminal
    By gemera in forum Linux Programming
    Replies: 8
    Last Post: 01-17-2013, 02:51 PM
  3. Replies: 7
    Last Post: 08-28-2011, 10:01 PM
  4. Getting screen size - unix/linux terminal
    By enok in forum C++ Programming
    Replies: 3
    Last Post: 11-21-2009, 04:56 AM
  5. Raw serial control in Linux
    By crepincdotcom in forum Networking/Device Communication
    Replies: 2
    Last Post: 09-12-2008, 01:17 PM
Website Security Test