SSH and open file for editing in same command












0















I have a command in a server that I edit with frequency. I have two do it in two steps: ssh to the server and vim the file. I’d like to do this in a single step, so I can alias it in my local shell. If I



ssh myserver vim /path/to/file


I get



Vim: Warning: Output is not to a terminal
Vim: Warning: Input is not from a terminal


Because ssh is expecting to just run the command and return the output. But what I need is for ssh to open the connection, stay there, execute the command and wait.



Is that possible, without having to do anything on the server?










share|improve this question



























    0















    I have a command in a server that I edit with frequency. I have two do it in two steps: ssh to the server and vim the file. I’d like to do this in a single step, so I can alias it in my local shell. If I



    ssh myserver vim /path/to/file


    I get



    Vim: Warning: Output is not to a terminal
    Vim: Warning: Input is not from a terminal


    Because ssh is expecting to just run the command and return the output. But what I need is for ssh to open the connection, stay there, execute the command and wait.



    Is that possible, without having to do anything on the server?










    share|improve this question

























      0












      0








      0








      I have a command in a server that I edit with frequency. I have two do it in two steps: ssh to the server and vim the file. I’d like to do this in a single step, so I can alias it in my local shell. If I



      ssh myserver vim /path/to/file


      I get



      Vim: Warning: Output is not to a terminal
      Vim: Warning: Input is not from a terminal


      Because ssh is expecting to just run the command and return the output. But what I need is for ssh to open the connection, stay there, execute the command and wait.



      Is that possible, without having to do anything on the server?










      share|improve this question














      I have a command in a server that I edit with frequency. I have two do it in two steps: ssh to the server and vim the file. I’d like to do this in a single step, so I can alias it in my local shell. If I



      ssh myserver vim /path/to/file


      I get



      Vim: Warning: Output is not to a terminal
      Vim: Warning: Input is not from a terminal


      Because ssh is expecting to just run the command and return the output. But what I need is for ssh to open the connection, stay there, execute the command and wait.



      Is that possible, without having to do anything on the server?







      ssh vim






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 17 at 2:38









      user137369user137369

      583723




      583723






















          2 Answers
          2






          active

          oldest

          votes


















          3














          ssh -t myserver vim /path/to/file



          -t

          Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.




          (source)






          share|improve this answer































            0














            Lot's of things here. I am assuming that the edit must be a manual edit, i.e. no ed or sed commands.
            1. Make sure your local machine has your xhost configured to allow a display from another node.
            xhost + just to test, if you are unsure.

            2. use ssh -X myserver vim /path/to/file
            3. you may need to specify the -n or -t option on the ssh command.

            4. do you have gvim installed? It can create an X11 window.

            5. You may have to execute the terminal window command, and have it execute vim.



            I've done this type of thing several times. I lot of it depends on your OS versions.






            share|improve this answer



















            • 1





              I neither have X (macOS local machine, headless server) nor do I want a GUI. The -t answer is what I was looking for.

              – user137369
              Feb 17 at 14:15













            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1406633%2fssh-and-open-file-for-editing-in-same-command%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            ssh -t myserver vim /path/to/file



            -t

            Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.




            (source)






            share|improve this answer




























              3














              ssh -t myserver vim /path/to/file



              -t

              Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.




              (source)






              share|improve this answer


























                3












                3








                3







                ssh -t myserver vim /path/to/file



                -t

                Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.




                (source)






                share|improve this answer













                ssh -t myserver vim /path/to/file



                -t

                Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.




                (source)







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 17 at 5:10









                Kamil MaciorowskiKamil Maciorowski

                28.5k156187




                28.5k156187

























                    0














                    Lot's of things here. I am assuming that the edit must be a manual edit, i.e. no ed or sed commands.
                    1. Make sure your local machine has your xhost configured to allow a display from another node.
                    xhost + just to test, if you are unsure.

                    2. use ssh -X myserver vim /path/to/file
                    3. you may need to specify the -n or -t option on the ssh command.

                    4. do you have gvim installed? It can create an X11 window.

                    5. You may have to execute the terminal window command, and have it execute vim.



                    I've done this type of thing several times. I lot of it depends on your OS versions.






                    share|improve this answer



















                    • 1





                      I neither have X (macOS local machine, headless server) nor do I want a GUI. The -t answer is what I was looking for.

                      – user137369
                      Feb 17 at 14:15


















                    0














                    Lot's of things here. I am assuming that the edit must be a manual edit, i.e. no ed or sed commands.
                    1. Make sure your local machine has your xhost configured to allow a display from another node.
                    xhost + just to test, if you are unsure.

                    2. use ssh -X myserver vim /path/to/file
                    3. you may need to specify the -n or -t option on the ssh command.

                    4. do you have gvim installed? It can create an X11 window.

                    5. You may have to execute the terminal window command, and have it execute vim.



                    I've done this type of thing several times. I lot of it depends on your OS versions.






                    share|improve this answer



















                    • 1





                      I neither have X (macOS local machine, headless server) nor do I want a GUI. The -t answer is what I was looking for.

                      – user137369
                      Feb 17 at 14:15
















                    0












                    0








                    0







                    Lot's of things here. I am assuming that the edit must be a manual edit, i.e. no ed or sed commands.
                    1. Make sure your local machine has your xhost configured to allow a display from another node.
                    xhost + just to test, if you are unsure.

                    2. use ssh -X myserver vim /path/to/file
                    3. you may need to specify the -n or -t option on the ssh command.

                    4. do you have gvim installed? It can create an X11 window.

                    5. You may have to execute the terminal window command, and have it execute vim.



                    I've done this type of thing several times. I lot of it depends on your OS versions.






                    share|improve this answer













                    Lot's of things here. I am assuming that the edit must be a manual edit, i.e. no ed or sed commands.
                    1. Make sure your local machine has your xhost configured to allow a display from another node.
                    xhost + just to test, if you are unsure.

                    2. use ssh -X myserver vim /path/to/file
                    3. you may need to specify the -n or -t option on the ssh command.

                    4. do you have gvim installed? It can create an X11 window.

                    5. You may have to execute the terminal window command, and have it execute vim.



                    I've done this type of thing several times. I lot of it depends on your OS versions.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Feb 17 at 4:49









                    Scottie HScottie H

                    715




                    715








                    • 1





                      I neither have X (macOS local machine, headless server) nor do I want a GUI. The -t answer is what I was looking for.

                      – user137369
                      Feb 17 at 14:15
















                    • 1





                      I neither have X (macOS local machine, headless server) nor do I want a GUI. The -t answer is what I was looking for.

                      – user137369
                      Feb 17 at 14:15










                    1




                    1





                    I neither have X (macOS local machine, headless server) nor do I want a GUI. The -t answer is what I was looking for.

                    – user137369
                    Feb 17 at 14:15







                    I neither have X (macOS local machine, headless server) nor do I want a GUI. The -t answer is what I was looking for.

                    – user137369
                    Feb 17 at 14:15




















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1406633%2fssh-and-open-file-for-editing-in-same-command%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Probability when a professor distributes a quiz and homework assignment to a class of n students.

                    Aardman Animations

                    Are they similar matrix