shell - Linux redirect input via proc fd0, dev/pts -


in ubuntu 13.04 using vmware, have 2 terminals(pid 1000 - /dev/pts0, pid 2000 - /dev/pts2) if terminal 2(/dev/pts2) ...

echo 'ls -al' > /proc/1000/fd/0 

i can see 'ls -al' prompts in terminal 0(/dev/pts0) however, visual result, not real command input terminal 0.

enter image description here

what want redirect actual command input terminal 2 terminal 0 via /proc/pid(terminal 0's)/fd/0 , execute command terminal 0.

is possible??, if is, how can this?

thank in advance.

this not possible, because bash 2 things when keyboard event <enter> happens.

  1. printing newline.
  2. executing entered command, if command completed.

the logic, when command completed not simple. depends on conditional statements, backslashes etc.

redirecting '\n' character stdin execute first step. guess impossible design, because shell, controlled shell horrible every security engineer.

on multi-user linux, able write , execute commands on shells, running different users (e.g. root). able nasty things (e.g. blame other users doing forbidden things).

if still need solution:

you write script, reads commands pipe , executes them under different user, beware: isn't secure.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -