0

I need my app to connect to a remote server via ssh, and run terminal commands. As far as I know, this is a non-interactive connection. Which differs from the one you open a terminal by yourself. I'm getting some errors right now when my app runs terminal commands. I want it to act exactly like I myself running these commands. So how can I achieve this? I'm a programmer not a Linux expert though.

  • 2
    Few things need to be clarified. I think "interactive" vs "non-interactive terminal" is not a useful distinction (if defined at all); there's "interactive" vs "non-interactive shell". The differences you observed may be because tty is not allocated on the remote side. ssh -t or ssh -tt may help; or (local) expect, if you need to "type" input not-too-soon or so. Can you provide mcve? You may omit "verifiable", but at least show us the commands you used and the errors you got. – Kamil Maciorowski Dec 08 '21 at 11:25
  • Thanks. I'm not using commands directly to connect to remote server. My app does it via a library. It can connect and run commands. I was wondering if something could be changed in the remote server after my app connects. right now I've set up my app to remove the line [ -z "$PS1" ] && return form .bashrc file. And it's working. I mean I get no more errors. But I don't know if it's a reliable solution. – james hofer Dec 08 '21 at 11:36
  • 1
    Please see this answer of mine to get context. The line you removed is a form of "twist number 3", you turned it off. Apparently your workflow needs some line(s) later in your .bashrc to be processed. It's possible some other line(s) shouldn't be processed, so the fact you entirely disabled the "twist 3" may bite you later. It may be good to identify the lines you need, re-enable the "twist 3" and place the needed lines before the "twist 3 line". Without seeing your .bashrc, the commands and the errors, it's hard to tell what the lines may be. – Kamil Maciorowski Dec 08 '21 at 21:20

0 Answers0