Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: copy terminal to vi, vi to terminal

  1. #1
    Join Date
    Oct 2010
    Location
    Canada
    Beans
    13
    Distro
    Ubuntu 10.10 Maverick Meerkat

    copy terminal to vi, vi to terminal

    I'm installing a fresh 12.04 server to a clean hdd (no desktop gui.) How can I copy lines from vi (a text file with commands that were useful and I have saved from previous installations) to the terminal, and also from the terminal to vi (to remember screen output concerning this installation.) Copying using Nyy in vi does not <shift><ctrl>c to the terminal.

    My typing is either fast or accurate, and I'm wasting a lot of time "copy typing" all my saved cron jobs, .conf files etc, from another screen on another server.

    Thanks - and apologies if this is a "newbie" question.

  2. #2
    Join Date
    May 2012
    Beans
    122

    Re: copy terminal to vi, vi to terminal

    Are you using a client like PuTTY to ssh in?

  3. #3
    Join Date
    Sep 2011
    Location
    Behind you!
    Beans
    564
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: copy terminal to vi, vi to terminal

    You need to use PuTTY. You can then copy from the terminal by using the mouse to select the text (auto copies to memory) and then right-click to paste whatever is in memory.

    LHammonds

  4. #4
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    6,074
    Distro
    Xubuntu

    Re: copy terminal to vi, vi to terminal

    I'm not aware of any way to do that kind of copy/paste in a tty, maybe because I don't know vi well enough.

    I always run up an ssh server as soon as possible, then do all the rest of the setup fron another machine that does have a GUI. Ssh from a GUI terminal allows copy/paste into vi sessions, and you can even use nautilus (thunar im my case) with sftp to drag/drop/copy/edit files.

  5. #5
    Join Date
    Jul 2008
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: copy terminal to vi, vi to terminal

    Quote Originally Posted by canucksailor View Post
    I'm installing a fresh 12.04 server to a clean hdd (no desktop gui.) How can I copy lines from vi (a text file with commands that were useful and I have saved from previous installations) to the terminal, and also from the terminal to vi (to remember screen output concerning this installation.) Copying using Nyy in vi does not <shift><ctrl>c to the terminal.

    My typing is either fast or accurate, and I'm wasting a lot of time "copy typing" all my saved cron jobs, .conf files etc, from another screen on another server.

    Thanks - and apologies if this is a "newbie" question.
    I also use a remote machine and login using SSH so I can use a ptty, but you can do what you want using only the tty on a single non-gui host. See here

  6. #6
    Join Date
    Oct 2010
    Location
    Canada
    Beans
    13
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: copy terminal to vi, vi to terminal

    <quote>I also use a remote machine and login using SSH so I can use a ptty, but you can do what you want using only the tty on a single non-gui host. See here</quote>

    Thanks to you all. The "see here" is for copying between 2 instances of vi (I do that regularly), not vi and terminal and vice versa.

    I was afraid you were all going to say "use SSH/Putty." I have never been there before. Just set up a Putty client on my desktop, tried to connect to the new server (and a couple of older ones) and get "connection refused". Guess this has something to do with the server not being set up correctly (12.04 with latest upgrade), or some sort of certificate. I'll have to look into that later... but if any of you have a "real quick reference page/cheat sheet" (for the server end and the certificates) that would be helpful.

    Again, thanks.

  7. #7
    Join Date
    Nov 2006
    Location
    Belgium
    Beans
    3,025
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: copy terminal to vi, vi to terminal

    +1 for all the putty or terminal (emulator) + ssh advice. I do that to.

    But you can avoid lots of copy/paste by copying (selected) known good conf files over the default ones from a clean install, eg with scp.

    Also, if you have a list of commands you need to run, you can simply turn that list in to a shell script, copy it over to the server, and execute it.

    You can take that a step further and also include the copy commands for your conf files in that script - eg by putting them on an intranet web server and wget them from the script. This approach is especially worth considering if you have multiple quit similar servers to set up, and as part of a recovery plan.

  8. #8
    Join Date
    Nov 2006
    Location
    Belgium
    Beans
    3,025
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: copy terminal to vi, vi to terminal

    get "connection refused"
    you need to
    Code:
    sudo apt-get install openssh-server
    on the server. That's all it takes to get started.

  9. #9
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    6,074
    Distro
    Xubuntu

    Re: copy terminal to vi, vi to terminal

    @redmk2:
    Yay, that works. I had a feeling it would be possible in vi.

    @canucksailor:
    tat trick with vi should get you by. If you want to execute commands that you have in a file, you can just create a file with the commands you want, and then run that filename.

    But it will pay off in time if you get that ssh server running and use a gui client on another machine for the rest of the work.

  10. #10
    Join Date
    Jun 2006
    Location
    Brisbane Australia
    Beans
    713

    Re: copy terminal to vi, vi to terminal

    Quote Originally Posted by LHammonds View Post
    You need to use PuTTY. You can then copy from the terminal by using the mouse to select the text (auto copies to memory) and then right-click to paste whatever is in memory.
    You can copy and paste in any linux terminal using the left mouse to select text, and then middle click to paste (not right click!).

    I find it very handy nowadays to use a clipboard manager. I use diodon but there are many for ubuntu (search the packages). The advantage is that they maintain a buffer of your clipboard. So I press ctrl+alt+v and a popup lists all my previous clipboard values which I can select from.

    Also note in vi/vim that you can edit another file using ":e /some/other_file" then switch back and forward with ctrl+6. Note that tab completion works when entering the file name here.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •