CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
files names and varibles

 



swaylock
Deleted

Apr 12, 2001, 4:30 PM

Post #1 of 3 (249 views)
files names and varibles Can't Post

I've installed about a dozen perl scripts and I've fairly adept at the command line but I've come up to a problem that is stumping me...Perhaps someone here can help me out. I have the following script:

#!/usr/bin/perl
#
# default_workgroup must have already been created
#
# This also assumes SPST is already running.

use APP;
require "APPcommon.pl";

my $UserName = shift || &Usage;
my $UserPass = shift || &Usage;
my $UserFN = shift || "";
my $UserLN = shift || "";

($UserLoginName,$UserDomainName) = split(/\@/, $UserName);

my $conn = APP->connect(
Host => $APP_SERVER,
Port => $APP_PORT
) or
die "Can't connect to APP Server: $APP::Errstr\n";

$conn->login(
USER => $APP_ADMIN_LOGIN,
PASSWORD => $APP_ADMIN_PASSWORD,
DOMAIN => $APP_ADMIN_DOMAIN) ||
die "Login failure: $APP::Errstr\n";

$conn->createMailbox (
MAILBOX => $UserLoginName,
PASSWORD => $UserPass,
WORKGROUP => $APP_DEFAULT_WORKGROUP,
DOMAIN => $UserDomainName,
FIRST_NAME => $UserFN,
LAST_NAME => $UserLN) ||
die "Create failure: $APP::Errstr\n";

print "User $UserLoginName\@$UserDomainName created.\n";

$conn->quit() || die "Can't quit: $APP::Errstr\n";
undef $conn;

sub Usage {
print <<"EOM";
usage: $0 user\@domain Password [First Name] [Last Name]
ie: $0 bob\@domain.com passw0rd Bob Jones
$0 bob\@domain.com passw13rd
EOM
exit;
}

END {
if ($conn) {
$conn->quit();
}

}


It's called APPAddUser. What it does is pass variables supplied to it to a "Safe Passage Secure Tunnel (SPST) client. It uses a module (APP.pm) and an another config file (APPcommon.pl) that both live in the same directory. The way that APPAddUser is written it looks like it should be an executable script - but it didn't come with a .cgi ending.

The problem I'm having is figuring out how to pass it the variables. If I call it from a browser: "http://mysite/APPAddUser" it just lists the script like a text file. I've tried renaming the script to APPAddUser.cgi and passing a query string to it but I get the error message flag at the bottom:

usage: $0 user\@domain Password [First Name] [Last Name]
ie: $0 bob\@domain.com passw0rd Bob Jones
$0 bob\@domain.com passw13rd

SO here I am stumped. I've never messed with stuff like this. How do you get non .cgi files to accept variables?

Any help would be greatly appreciated. (I'm sort of in a time crunch so I'm going to post this question at a few more discussion forums..so forgive me for cross posting).

Mike




Jean
User


Apr 14, 2001, 11:50 PM

Post #2 of 3 (239 views)
Re: files names and varibles [In reply to] Can't Post

It looks like a regular command line script, i.e. you're not
supposed to execute it from a browser, but from command line.
Use the example that the sript shows when executed without parameters.

In more details:
In case you wand to add a user 'John Doe', you can write
perl APPAddUser.pl johnd@perlguru.com qwerty John Doe
That is supposed to add a user with following parameters:
Username: johnd
Password: qwerty
First name: John
Last name Doe

Jean Spector
QA Engineer @ Extent Technologies, Ltd.
mage@lycosmail.com


swaylock
Deleted

Apr 16, 2001, 12:19 PM

Post #3 of 3 (232 views)
Re: files names and varibles [In reply to] Can't Post

Jean,

Thanks for the reply. I realize that what I need to do is pass the variables to the script via header/form information.

I found a great tutorial for doing just that here:

http://wyrd.hood.edu/~echang/csci583/Spring01/handouts/basics/perlbasics2.shtml

Thanks for your reply.

Mike

http://wyrd.hood.edu/~echang/csci583/Spring01/handouts/basics/perlbasics2.shtml


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives