Geeks Talk

Prepare for your Next Interview




Difference in these UNIX commands

This is a discussion on Difference in these UNIX commands within the Unix/Linux forums, part of the Operating Systems category; Can someone tell me the difference between these commands namely? ctermid(), ttyname(), cuserid(), getlogin()...


Go Back   Geeks Talk > Operating Systems > Unix/Linux

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 06-24-2006
Expert Member
 
Join Date: May 2006
Location: New York, USA
Posts: 118
Thanks: 0
Thanked 6 Times in 4 Posts
RyanJames is on a distinguished road
Difference in these UNIX commands

Can someone tell me the difference between these commands namely?
ctermid(), ttyname(), cuserid(), getlogin()
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-24-2006
Contributing Member
 
Join Date: May 2006
Posts: 79
Thanks: 0
Thanked 5 Times in 4 Posts
fred is on a distinguished road
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.
Reply With Quote
  #3 (permalink)  
Old 06-24-2006
Contributing Member
 
Join Date: May 2006
Posts: 84
Thanks: 0
Thanked 9 Times in 6 Posts
timmy is on a distinguished road
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
Reply With Quote
The Following User Says Thank You to timmy For This Useful Post:
  #4 (permalink)  
Old 06-24-2006
Contributing Member
 
Join Date: May 2006
Posts: 88
Thanks: 0
Thanked 10 Times in 9 Posts
norman is on a distinguished road
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
Reply With Quote
  #5 (permalink)  
Old 07-12-2006
Contributing Member
 
Join Date: May 2006
Posts: 66
Thanks: 1
Thanked 5 Times in 4 Posts
janelyn is on a distinguished road
Re: Difference in these UNIX commands

The syntax for cuserid() is
#include
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.
Reply With Quote
Reply

  Geeks Talk > Operating Systems > Unix/Linux


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
difference between QTP and WinRunner georgeprakash WinRunner 18 3 Weeks Ago 01:43 AM
Linux and UNIX - Which is better blenda Unix/Linux 4 06-25-2008 07:53 AM
Difference between Usability and Functional Testing sunny_love Testing Issues 12 10-08-2007 02:08 AM
Signal Handling in UNIX blenda Unix/Linux 2 02-08-2007 02:17 AM
Semaphore in UNIX blenda Unix/Linux 2 06-22-2006 02:26 PM


All times are GMT -4. The time now is 01:05 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved