Re: pseudo terminals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,


On Thu, 2009-09-17 at 08:09 +1000, Cameron Simpson wrote:
> On 16Sep2009 19:43, devi <devi@xxxxxxxxxxx> wrote:
> | On Wed, 2009-09-16 at 11:18 +0100, Dave Mitchell wrote:
> | > On Wed, Sep 16, 2009 at 03:06:09PM -0400, devi wrote:
> | > > 	The command 
> | > > echo "service httpd status " > /dev/pts/1 is executed on one terminal,
> | > > let us assume it as t1.  
> | > > The echo command is executed on t1 but the output(service httpd status"
> | > > is directed to /dev/pts/1 terminal.
> | > > 
> | > > What I am saying is that the output  is redirected directly to the
> | > > terminal /dev/pts1/1.
> | > > The output here is "service httpd status", which is generally a command.
> | > > And so it gets executed.
> | > 
> | > No, the text just appears in the terminal associated with /dev/pts1/1;
> | > it does not not cause the command to be executed. That is to say,
> | > you can't use this as a mechanism to insert characters into a another
> | > terminal's input buffer.
> | > 
> | But the command got executed, and it gave the status of apache
> | on /dev/pts/1 terminal.
> 
> That's quite interesting. It should _not_ cause the command to be
> executed, and I really believe something more is going on.
> 
> /dev/pts/1 is the "slave" side of the pseudoterminal; all pseudoterminals
> have a "master" side and a "slave" side.

Here, the /dev/pts/1 is the tty of a virtual machine.  This virtual
machine is created by xen.
Yes, I have come across master and slave pseudo terminals, but I have
not set any anything like that.
> 
> The slave side is the "normal" terminal side that programs are connected to.
> Writing to it causes text to the displayed, and reading from it consumes text
> that is typed.
> 
> The master side is what terminal emulators like xterm use. Xterm is a
> GUI program that displays a terminal on your screen. When you type at
> the displayed GUI, xterm catches that and writes data to the _master_
> side of the pseudo terminal it obtained. That stuff appears as though
> typed to ordinary programs on the slave side. Conversely, data _read_ by
> xterm from the master side is the data _written_ to the slave side;
> xterm gathers that and updates the GUI, thus displaying the program
> output.
> 
> See "man ptmx" for how a pseudo terminal is obtained under Linux.
> 
> Anyway, because of this scheme nothing you write to /dev/pts/1, a slave
> device, should cause it to be _typed_ at that terminal.
> 
> Can you confirm your setup in more detail?

There is no setup, I created the virtual machine, and then found its
tty. and executed the command from other terminal "t1" as specified
earlier.


> 
> I would imagine that you have two terminals open, with plain shells in
> them. Typing the command "tty" in each will tell you their names, and
> presumably one says "/dev/pts/1". The other is "t1".
> 
> And you are really typing:
>   echo "service httpd status" >/dev/pts/1
> in the "t1" terminal, and on the /dev/pts/1 terminal you are not seeing the
> string "service httpd status" displayed as plain output; instead you are
> seeing the output of the command:
>   service httpd status
> 
> Is that all correct?
> 
> Can I suggest the following experiments?
> 
> First, run the command "set -x" in the shell on /dev/pts/1. That will turn
> of execution tracing, and it should then be more obvious is that shell
> is really executing the command. Type some commands in that shell, like
> "date" or "uptime" to see the effect. Then do your echo statement from
> "t1" again.
> 
> Secondly, on the "t1" terminal, run the command:
>   echo -n "service httpd status" >/dev/pts/1
> You should see it displayed on /dev/pts/1 but it won't run a command
> because we have not sent the end-of-line. If you're right, it will be
> as though typed, and you can go to the other terminal and edit the line
> and change it before pressing enter.

I have done, what you suggested, it's the same.  Anyways my requirement
is that, after the command is executed on /dev/pts/1, I should be able
to get the return value on the terminal "t1"

eg:
	rc=`echo "service httpd status" > /dev/pts/1"
I thought rc will hold the return value, but it displays nothing.


> 
> Cheers,
> -- 
> Cameron Simpson <cs@xxxxxxxxxx> DoD#743
> http://www.cskk.ezoshosting.com/cs/
> 
> It's a vague science.   - Rory Tate, circle researcher.
> 

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux