SSH and open file for editing in same command
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
add a comment |
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
add a comment |
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
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
ssh vim
asked Feb 17 at 2:38
user137369user137369
583723
583723
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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 ifssh
has no local tty.
(source)
add a comment |
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.
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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 ifssh
has no local tty.
(source)
add a comment |
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 ifssh
has no local tty.
(source)
add a comment |
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 ifssh
has no local tty.
(source)
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 ifssh
has no local tty.
(source)
answered Feb 17 at 5:10
Kamil MaciorowskiKamil Maciorowski
28.5k156187
28.5k156187
add a comment |
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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