help icon indicating copy to clipboard operation
help copied to clipboard

How to open terminal/shell session via server request

Open ORESoftware opened this issue 6 years ago • 5 comments

I can open up bash and type commands from my local terminal into a remote bash process like so:

const net = require('net');
const cp = require('child_process');

const server = net.createServer(s => {

  const bash = cp.spawn('bash');
  s.pipe(bash.stdin, {end:false});
  bash.stdout.pipe(s);
  bash.stderr.pipe(s);


});

server.listen('4004');

but the problem is, I don't get prompts like this:

<hostname>:<basename> <user> $`

I just get blank space which I can type into which is different than a terminal

ORESoftware avatar May 16 '19 18:05 ORESoftware

I am still looking for answers to this, I updated the question with a bounty here: https://stackoverflow.com/questions/56174957/open-up-shell-on-server-via-http-request/56175507

ORESoftware avatar May 22 '19 17:05 ORESoftware

I ran bash with output as console and with output redirecting to a file. In the former case, the bash itself prints the necessary eye-catcher text, but in later, it does not.

So it looks like in our case we won't have it coming from bash.

gireeshpunathil avatar Nov 06 '20 12:11 gireeshpunathil

in either way, can you try forcing interactive flag ? cp.spawn('bash', ['-i']);

I am not sure whether it will have any other side effect on other parts of its execution though

gireeshpunathil avatar Nov 06 '20 12:11 gireeshpunathil

@ORESoftware - is this resolved?

gireeshpunathil avatar Jun 22 '23 11:06 gireeshpunathil

It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] avatar May 15 '24 01:05 github-actions[bot]

It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] avatar Jun 14 '24 01:06 github-actions[bot]