Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit CGI script from Perl

Status
Not open for further replies.

Trancemission

Technical User
Joined
Oct 16, 2001
Messages
108
Location
GB
I am attempting to create a perl script (Could use shell) that will take paramaters and pass them to a website. I want to do this without the use of html or a web browser.

The reason for this is I have a SMS gateway that sends SMS's from a webform. At the minute I goto a web page, fill out the form and submit it to a page called I want to create a script that will 'submit' my form from the command line. I am not worried about seeing the conformation page to say the SMS has been sent becauase it always goes to the same page.


Cheers

Trancemission
=============
If it's logical, it'll work!
 
I don't understand the question, yet. Can you expound upon the problem a little more? [poke] 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
I have a monitoring system that monitors devices on my network. If a node goes down it can execute a command and pass paramaters about what node has gone down with it.

The command that it executes at the minute is simply a 'mail' command (UNIX) which emails me the details.

I want the command to 'submit' a form to a webpage using http POST. This webpage can then SMS me or anybody else, depending on who I want it to.

Trancemission
=============
If it's logical, it'll work!
 
You can write a piece of perl that makes an http request like,
Code:
#!/usr/local/bin/perl
use LWP::Simple;
$uri = '[URL unfurl="true"]http://your_web_server/cgi-bin/a_mail_app.cgi?var1=stuff&var2=more_stuff';[/URL]
$content = get("$uri");

When a node goes down, fire off that code which makes a request to your web server. You don't care about the answer, you just need it to fire the request at the web server. On the web server, do something like,

Code:
#!/usr/local/bin/perl
use strict;
use CGI;
my $cgi = new CGI;
print $cgi->header, $cgi->start_html, $cgi->end_html;

$var1 = $cgi->param('var1');
$var2 = $cgi->param('var2');

# do your mail stuff based on the inputs (var1 and var2).


If that does not give sufficient flexibility and control you
could look at using LWP::UserAgent. See perldoc LWP for the docs on LWP.
'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top