different shells

Phil Burch pburch at oralis.com
Tue Aug 31 15:39:47 GMT 1999


I wrote some quick and ugly c that changes the netbios name of a dos for
lanman client in system.ini

You could change it to edit Win.ini

Phil Burch
Network Administrator
http://www.Oralis.com

-- code below
#include <process.h>
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <string.h>

int main(int argc, char *argv[]){
  FILE *infileh;
  FILE *outfileh;
  char input[80];
  char sysfile[] = "C:\\Net\\SYSTEM.INI";
  char tempfile[] = "C:\\Net\\SYSTEM.TMP";
  char syscmd[80] = "copy ";
  strcat(syscmd, tempfile);
  strcat(syscmd, " ");
  strcat(syscmd, sysfile);
 
  if(argc < 2){
    printf("MSNAME ERROR:\tNo name specified!\n\t\tUsage MSNAME
XXXX_XX\n");
    return 0;
  }
  
  if((infileh = fopen(sysfile, "rt")) == NULL){
    printf("MSNAME ERROR: Error opening input file %s\n", &sysfile);
    return 0;
  }
  if((outfileh = fopen(tempfile, "wt")) == NULL){
    printf("MSNAME ERROR: Error opening output file %s\n", &tempfile);
    return 0;
  }
  
  while(!(feof(infileh))){
    fgets(input, 80, infileh);
    if(!(strncmpi(input, "computername", 12) == 0)){
      fprintf(outfileh, input);
     } else {
      if((fprintf(outfileh, "computername=%s\n", argv[1])) == EOF){
        printf("Error writing to file!\n");
        fclose(infileh);
        return 0;
      }
    }
  }
  fclose(infileh);
  fclose(outfileh);
  if(system(syscmd) != 0){
    printf("MSNAME ERROR: Error executing syscmd!\n");
    return 0;
  }
return 1;
}




-----Original Message-----
From: Stephen Waters [mailto:swaters at amicus.com]
Sent: Tuesday, August 31, 1999 8:21 AM
To: Multiple recipients of list SAMBA-NTDOM
Subject: Re: different shells


Joel Miles wrote:
> 
> > Well, with some REALLY complex scripting, you might be able to
accomplish
> > that.  You know, parse win.ini, check to see what the value of the
SHELL
> > line is, compare that to what it should be for that user.  If it's
> > different, replace it and reboot, if it's the same, then just log
them in.
> > Greg
> 
> Do you know where I could get some help in writing this (also, what
language
> would I use, Perl?)?

if you have perl for win32 on all of your workstations, this might be
workable. otherwise, you should probably use a .bat file with some
decent text manipulation utilites (kind of a "cat win.ini |grep shell"
bash comparison thing), though i'm not a .bat genius.

just a thought,

-stephen


More information about the samba-ntdom mailing list