in reply to cgi script error

$name = system "useradd $input";

perldoc -f system tells us that "The return value [of system] is the exit status of the program".

You want to check that with something like 0 == system @command_and_args or die "system didn't do it for me: $?" ( using the 0== so as to get something false when system returns a non-zero exit code allowing the use of use or die that folks are used to)

Also, some general complaining about style. All the prints in your first script (that generate the html form) would look less "smelly" if you were to use a heredoc or other quotelike or just a plain html file instead of a perl script.

I like your use of print $cgi->header(); in the second script, too.

@_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;

Replies are listed 'Best First'.
Re^2: cgi script error
by adam_blackice (Acolyte) on Apr 09, 2007 at 03:28 UTC
    thanx for you help ...,
    but iam a newbie that want to make asimple program that
    adminstarte the lunix enviroment
    how can i think about that ?
    i think when iam using the system function i can use it to administarte the linux enviroment throw it..
    So how can i think about something like that
    and thanx for all

      It won't help you with your perl, but there are many other controll panels which do all of that and more.

      If you're just wanting to do it as an exercise, I'd say admin on a unix-like is not a good starting project.

      To do it, you'd need a daemon running as root (so you have the permissions) that is given commands through some sort of queue mechanism (like a table in a database or some funky inter process communication to get the messages across. Running CGI scripts as root is likely to end badly even if you do all the things listed in perlsec (like using -T)

      Proc::Daemon will give you your daemon, you can just connect to the database, and then check (say every minute) for rows in the stuff_to_do table...

      'tis a big task...

      Also there was an example of your useradd in either Perl for System Administration or Automating UNIX and Linux Administration. I'm not sure which.

      @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;
        thanx mr. F00li5h i mean mr. intelligent :)
        i will tell you what i understood from u .....
        first: i will make a table or something by using Mysql and add the different user records like UID and Password .....
        and then use adatabase DBI connection or something? ....to connect between DB and my script but what will make the connection between the DB and the system like adding the new account to the /etc/passwd....,
        or you mean that i will using the DB to just call the password root from there
        forgive me for my dummy questions but iam really needing your help