Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

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 Blogs FAQ Tag Cloud 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 6 Times in 5 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 11 Times in 7 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 6 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
difference between QTP and WinRunner georgeprakash WinRunner 18 11-10-2008 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 06:47 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved