Results 1 to 5 of 5

Thread: Difference in these UNIX commands

  1. #1
    Expert Member
    Join Date
    May 2006
    Answers
    114

    Difference in these UNIX commands

    Can someone tell me the difference between these commands namely?
    ctermid(), ttyname(), cuserid(), getlogin()


  2. #2
    Contributing Member
    Join Date
    May 2006
    Answers
    71

    Re: Difference in these UNIX commands

    The ctermid() function generates a string that, when used as a pathname, refers to the current controlling terminal for the current process.


  3. #3
    Contributing Member
    Join Date
    May 2006
    Answers
    82

    Re: Difference in these UNIX commands

    ttyname() - This returns name of a terminal.
    cuserid() - This get character login name of the user
    getlogin() - This returns a pointer to a string containing the user name associated by the login activity with the controlling terminal of the current process


  4. #4
    Contributing Member
    Join Date
    May 2006
    Answers
    85

    Re: Difference in these UNIX commands

    Interesting to learn!!!! The associated header files for each are given below:
    ctermid() - stdio.h
    ttyname() - unistd.h
    cuserid() - stdio.h
    getlogin() - unistd.h


  5. #5
    Contributing Member
    Join Date
    May 2006
    Answers
    64

    Re: Difference in these UNIX commands

    The syntax for cuserid() is
    #include <stdio.h>
    char *cuserid(char *t);

    The function cuserid() gives the user id associated with the process.
    The interesting part is in the return values of this function cuserid() namely
    If t is not a null pointer but if the associated login id or name could not be found then *t is placed with '\0' which denotes a null byte.
    If t is a null pointer and if the associated login id or name could not be found then return value from this function is a null pointer
    If t is a null pointer and if the associated login id or name can be found then return value from this function is the address of the storage area which has the corresponding login id or the username of the process.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact