/dev/tty?

/dev/tty?

Post by predato » Wed, 26 Apr 2000 04:00:00



Well im just a simple user of UNIX so am not root...And i and my frien
wants to communicate beatwen us...I know that i can use write but i want
to write hime message like a write command and i tryed to open /dev/tty?
tty? is tty wher is my friend...But it always faild...We dont have
permisions...And whebn i use write it is OK...How to write to my friend
or how to open /dev/tty! like write...
I have once tried to use root acount to write with my program and it
works but when im  a simple user it alway faild...

OK here is my program its a C++ with <stdio.h>::

#include<stdio.h>
#include<iostream.h>

int main(){

FILE *stream=fopen("/dev/tty12","a");
 if (stream==NULL){
   cout<<" Faild to open /dev/tty12"<<endl; //it always fail whan im not
root
    exit(1);
  }
char *msg=new char[50];
int sockfd;
cin.get(msg,49);
sockfd=fileno(stream); //i also used
fprintf(stream,"&s",msg);fflust(stream);
write(sockfd,msg,50);
return(0);

Quote:}

his program works only when i run it as root but how then work write...?

If someone have source cod of wite command please send it to me :

 
 
 

/dev/tty?

Post by Barry Margoli » Wed, 26 Apr 2000 04:00:00



>Well im just a simple user of UNIX so am not root...And i and my frien
>wants to communicate beatwen us...I know that i can use write but i want
>to write hime message like a write command and i tryed to open /dev/tty?
>tty? is tty wher is my friend...But it always faild...We dont have
>permisions...And whebn i use write it is OK...How to write to my friend
>or how to open /dev/tty! like write...

The write command is set-gid to the group that all /dev/tty* devices are
owned by, which allows it to write to anyone else's terminal.  Unprivileged
programs can't do this.

--

Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

1. Getting the real tty device name (/dev/tty not good enough)

Does anyone have any handy code that works on Sun to dope out the real
device name of the controlling terminal for a process? /dev/tty is just
not good enough for what I need to do.

Send mail to me and I will summarize.

Thanks in advance.

--

Olan           uucp: rutgers!bcm!sob             and Systems Support
Barber         Opinions expressed are only mine. Baylor College of Medicine

2. HELP!

3. /dev/ttyS? vs /dev/cua?

4. What is LDAP's rpm name?

5. diff between /dev/tty and /dev/pts

6. HPT366 again

7. /dev/cua /dev/ttyS and getty_ps

8. HELP!!: Virtual Hosting on AIX??

9. /dev//dev/tty: No such file or directory when requesting uptime

10. syslogd: "/" in "/dev//dev/tty"

11. kermit cannot open /dev/tty, /dev/cua1?

12. Getting unexpected syslogd: '/' in "/dev//dev/tty"