Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: deleting a ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 11045 of 11531
Post > Topic >>

Re: deleting a user name from a file

by rob.dixon@[EMAIL PROTECTED] (Rob Dixon) May 9, 2008 at 08:40 PM

Lokeey wrote:
> 
> Rob thanks for your input. Yes the * is a typo or pasted somehow. Rushed
> and wasn't paying attention, and worked on it some more after I sent
> that out and thought about how the ARGV and my other syntax, it didn't
> make sense to me. But I saw your comment just now and had already taken
> out the ARGV. Here's what I have so far. I'm just not sure how to lay
> out my loop, (while or if)
> 
> /#!/usr/bin/perl -w

Always

  use strict;
  use warnings;

and Perl will tell you about many simple mistakes that you may have made.

> # this script removes a user from sudoers file
> 
> print "Enter Site-ID: "; $site = <STDIN>;
>    chomp($site);
> 
> print "\nEnter the username to remove from /$site/local/etc/sudoers: " ;
> $user = <STDIN>;
>    chomp($user);
> 
> # confirm user to be removed
> 
> print "\n$user will be removed from /$site/local/etc/suders. ";
> 
>   open FILE, "@[EMAIL PROTECTED]
" or die
>   "cannot open sudoers for $sites. ";/
> 
> *### not exactly sure how to lay out my loop or if i should use while or
> if statements###*
> /
> print "Done! User $user has been removed from $site sudoers. \n";/

OK, but you've now removed everything to do with the real purpose of the
program. I know it's tempting to write at least /something/, but all
you've done
is to pretend to gather parameters for a procedure that you haven't yet
defined.
Throw all this away, which is nothing to do with what the program really
does,
and write


  use strict;
  use warnings;

  my $site = 'sss';
  my $user = 'uuu';

and then start to fill the rest out. I gave you many hints in my previous
post
so please look at that again. The first thing is to define what your
program
does and what command-line parameters it expects, so I think you should
start by
writing the usage text as I showed:

die <<USAGE unless @[EMAIL PROTECTED]
  This program should be run with command-line parameters like this:
    :
  And does this:
    :
USAGE

and change that text until you are happy to commit to it and make your
program
do what it says it does.

Rob
 




 4 Posts in Topic:
deleting a user name from a file
lokeey@[EMAIL PROTECTED]   2008-05-09 07:35:03 
Re: deleting a user name from a file
rob.dixon@[EMAIL PROTECTE  2008-05-09 18:56:35 
Re: deleting a user name from a file
rob.dixon@[EMAIL PROTECTE  2008-05-09 20:40:00 
Re: deleting a user name from a file
lokeey@[EMAIL PROTECTED]   2008-05-09 13:49:13 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 19:17:43 CDT 2008.