Command Line Login script to GroupWise WebAccess

I am working on a command line batch script for linux, that is aimed at logging in to a GroupWise WebAccess server.

I want todo this to verify the status of the Agent that reports it being up/ok, while it does not always neccesarily mean just that when its through the WebAccess portion of our mail system.

I've already made a script thats able to DL and check for the proper front page, however, I am unable to log in to WebAccess this way. I've tried using both WGET and CURL to DL the cookies, they still end up blank.
# These are the code snippets I've used while trying to DL the cookie:
 
wget \
    --no-check-certificate \
    --save-cookies ~/webmailcookie \
    --post-data "User.id=******&User.password=*******" \
    -O - \
    https://webmail/gw/webaccess \
    > /dev/null
 
 
 
curl \
    -k \
    --cookie-jar ~/webmailcookie \
    --data "User.id=****&User.password=*******" \
    https://webmail/gw/webaccess \
    > /dev/null

Open in new window

LVL 2
TheFlyingCorpseAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

saurabhpendharkerCommented:
Hello,

You may try this:

#!/usr/local/bin/perl -w
#use LWP::Debug qw(+);  (Uncomment this if you want to see more debugging)
 
use WWW::Mechanize;
use WWW::Mechanize::DecodedContent;
 
$user='<USERNAME>';
$pass=`<PASSWORD>`;
 
$url = 'https://<WEB ADDRESS>';
 
$m = WWW::Mechanize->new();

$m->get($url);
 
$m->form_name("<FORM NAME>");
 
$m->set_fields(<Username Text Field Name on webpage> => $user, <PASSWORD TEXT Field Name on Webpage> => $pass);
 
$m->click();

print $m->content();
 
This will display the contents once you are logged into the webpage using given credentials.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TheFlyingCorpseAuthor Commented:
haha, this is too good to be true, it works(slight modification to the set fiels, had to enclose the fields with '' to make it understand it correctly.

Thank you a bunch!
TheFlyingCorpseAuthor Commented:
The expert who answered had good knowledge of coding and it was easy to understand his sollution.

The only thing I had todo was install the extra PERL modules, and it was flying away with the solution I asked for!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.