Hi
I'm actually building a web interface to a news group server (INN).
One of the feature is to allow a few users to create and delete newsgroups
from the web. Basically, using CGI.pm, I retrieve the newsgroup's name,
whether the user ask for a creation or a deletion of a newsgroup, and
launch a few commands.
Normally, from the shell, I would perform the following operations to
create or remove a newsgroup (I will setuid the ctlinnd because ctlinnd
needs to be executed as the "news" user):
/usr/local/news/bin/ctlinnd pause "modification of active file"
/usr/local/news/bin/ctlinnd rmgroup/newgroup name_of_the_newsgroup
/usr/local/news/bin/ctlinnd reload active "reload active file"
/usr/local/news/bin/ctlinnd go "modification of active file"
If the server successfully performed the command, ctlinnd will exit with a
status of zero and print the reply on standard input. If the server could
not perform the command (for example, it was told to remove a newsgroup
that does not exist), it will direct ctlinnd to exit with a status of one.
It's not clear to me how I could retrieve the status code. I would also
like to know whether the way I use system() is right or if there is a
better way to do what I'm tryining to do.
You will find below the script on which I'm working
Have a nice day all
Ga�l
-------------------------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
$query = new CGI;
$newsgroup_name = $query->param('newsgroup_name');
$action = $query->param('submit');
sub get_{
system `/usr/local/news/bin/ctlinnd pause "modification of active
file"`;
if ($action eq 'Add') {
system `/usr/local/news/bin/ctlinnd newgroup $_[0]`;
my $result = 1;
}
elsif ($action eq 'Remove') {
system `/usr/local/news/bin/ctlinnd rmgroup $_[0]`;
my $result = 2;
}
system `/usr/local/news/bin/ctlinnd reload active "reload active
file"`;
system `/usr/local/news/bin/ctlinnd go "modification of active
file"`;
}
&get_($newsgroup);
print "Content-Type: text/html\n\n";
print "<html> <head>\n";
print "<title>Manage newsgroups</title>\n";
print "</head>\n";
print "<body>\n";
if ($result eq '1') {
print "The newsgroup has been added";
} elsif ($result eq '2') {
print "The newsgroup has been removed";
print "</body> </html>\n";