-1

RH6. Is it possible to issue, for example, a cd command in a running xterm process FROM a different process? I know the pid of the existing xterm proc. I actually want to "echo" a message first, and then cd. Something like...

echo "Your time in this workarea has expired.  You are being sent home"
cd ~

It would be great if I could do this as a different user somehow (not the owner of the target proc) (I am not and cannot be root). But if that is not possible, perhaps having the target xterm owner create an executable which wraps these commands inside, and then setting the sticky bit on the executable might work when the 2nd proc goes to run it. Not sure if lint checking will catch this as some sort of foul.

daveg
  • 1,051
  • 11
  • 24
  • No, it's not generally possible. You'd need to be able to open the master pty for the xterm's tty device, and write to that. But there's no general way to find this out. – Barmar Sep 06 '18 at 19:17
  • [Executing string sent from one terminal in another in Linux pseudo-terminal](https://stackoverflow.com/q/8677623/608639) – jww Sep 06 '18 at 19:54

1 Answers1

0

I would just make this a comment, but I don't have enough reputation. But I think this might be on the right track:

https://serverfault.com/questions/178457/can-i-send-some-text-to-the-stdin-of-an-active-process-running-in-a-screen-sessi

William
  • 145
  • 2
  • 15
  • The 1st answer to the link you provided may be "good enough". It would allow me to send some text to stdin which tells the user their time is expired and ask them to leave. However, this solution doesn't work. The string I echo to /proj//fd/0 is not echoed on the xterm. Any ideas why this doesn't work ? – daveg Sep 06 '18 at 19:41
  • Well, it's proc not proj. Check out the bottom answer too. – William Sep 06 '18 at 19:50
  • Ya, typo here (proj = proc), but not in the actual test. – daveg Sep 06 '18 at 21:02
  • The screen and tmux solutions seem to want me to start the server. My users are already running an xterm in which they run my script. I don't see how they can work for me. – daveg Sep 06 '18 at 21:05
  • Yeah I was talking about the very last one. It doesn't have anything to do with screen or tmux. – William Sep 06 '18 at 21:15