GIDForums  

Go Back   GIDForums > Computer Forums > Computer Software Forum - Linux
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-May-2004, 16:18
emmie emmie is offline
New Member
 
Join Date: Mar 2004
Posts: 12
emmie is on a distinguished road

linux system calls


hi everyone...
i'm new in this forum & i want some help, i've a project from my lecturer about making a program to create a new user, new password, delete password, create group name & password.

my Question is what system calls can accomplish these tasks,or where can i find help
thnx.......
  #2  
Old 13-May-2004, 17:03
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Quote:
Originally Posted by emmie
hi everyone...
i'm new in this forum & i want some help, i've a project from my lecturer about making a program to create a new user, new password, delete password, create group name & password.

my Question is what system calls can accomplish these tasks,or where can i find help
thnx.......

Hi emmie. These will definitely have to be system calls. Here are some man pages that you can look through:
Code:
man useradd man passwd man userdel man groupadd

The passwd command can be used to set both group passwords and user passwords.

HTH,
darrin
  #3  
Old 18-May-2004, 17:43
emmie emmie is offline
New Member
 
Join Date: Mar 2004
Posts: 12
emmie is on a distinguished road
hi dsmith
i was so busy with another projects than to follow up the linux project,now my question is there any header files i 've to include while using this commands or just i refer them in my code.
thnx in advance.
  #4  
Old 18-May-2004, 18:28
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Quote:
Originally Posted by emmie
hi dsmith
i was so busy with another projects than to follow up the linux project,now my question is there any header files i 've to include while using this commands or just i refer them in my code.
thnx in advance.

These all need to be called as system calls. I don't believe that any of these can be called as a C function call because they involve passwords and potentially different ways of doing things in different *nixes. What you need to do is use the system command along with the sprintf command.

Example:
CPP / C++ / C Code:
#include <stdlib.h>  //system command
#include <stdio.h>   //sprintf command

int main()
{
  char username[80];
  char response[10];
  char system_call[100];

  printf("Enter the name of the user that you want to delete: ");
  fgets(username,79,stdin);
  *(username+strlen(username)-1) = 0;
  printf("Do you want to delete the users home files? ");
  fgets(response,9,stdin);
  if(toupper(response[0])  == 'Y')
    sprintf(system_call,"userdel -r %s",username);
  else
    sprintf(system_call,"userdel %s",username);
  system(system_call);
  return 0;
}

That's untested, but should give you the idea.

HTH,
d
  #5  
Old 23-May-2004, 15:41
emmie emmie is offline
New Member
 
Join Date: Mar 2004
Posts: 12
emmie is on a distinguished road
hi dsmith,
thank u very much for u'r help. i really appreciate that. i've tried out u'r idea with some modification & it works fine. u should add the path of the info u wanna change before writing the line code that would make this change; like
"/usr/sbin/ userdel -r %s"............
i'm sorry for being late in reply,but i was very busy doing this project beside 2 other projects...........
thnax again.
 
 

Recent GIDBlogToyota - 2008 November Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to boot Linux in text mode with GRUB Loader JdS Computer Software Forum - Linux 8 11-Jul-2006 05:41
Mozilla Thunderbird dsmith Computer Software Forum - Linux 9 01-Mar-2005 12:56
Linux Font Improvement Mini-howto dsmith Computer Software Forum - Linux 1 20-Feb-2005 07:37
Changing monitors on a Linux machine JdS Computer Software Forum - Linux 10 23-Dec-2004 10:49
Linux Kernel Upgrade Mini Howto dsmith Computer Software Forum - Linux 3 05-Apr-2004 23:10

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:12.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.