CGI Paging Script Configuration Issue

Hi,

I'm new to CGI scripting, and need to get a CGI script to work for paging employees. I have a 'sendpage.cgi' CGI script, but I need some help configuring it with the paging service variables and employee pager pin numbers. I also need some help on where to post the script on my Web Server, I'm running SunOS 4.1.4 on a Sparc. Any help will be greatly appreciated, this is all new for me.

Thank you.

---------------------------------------------------------

I am using Netscape FastTrack Web Server for SunOS. As you requested, here is the sendpage script I am trying to make work.

#!/usr/local/bin/perl
#
# sendpage - Program to send a page using sendpage.
#
# Copyright (C) 1996         Mowgli C. Assor          (Sprawl Software)
#
# 96/05/19 - Started the original program.
#
##
$WEBMASTER="webmaster@my.domain.com";
$PROG = "/web/sendpage";
##
$debug = 0;

if ($ENV{'REQUEST_METHOD'} eq 'POST')
{
  read(STDIN, $BUFFER, $ENV{'CONTENT_LENGTH'});
}

if ($BUFFER ne "")
{
  if ($debug) { &html_header("Debug Info"); }

  @pairs = split(/&/, $BUFFER);

  foreach $pair (@pairs)
  {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
    if ($debug) { print "$name : $value\n"; }
  }

  -x $PROG || die "Could not find executable $PROG!\n";

  if (($FORM{'to'} ne "") && ($FORM{'message'} ne "") && ($FORM{'from'} ne ""))
  {
    if ($FORM{'to'} eq "Group User") { $pcmd=$PROG . " groupid"; }
    if ($FORM{'to'} eq "Primary User") { $pcmd=$PROG . " userid"; }

    if (! $debug) { &html_header("Page Queued"); }

    $message = "";
    if ($FORM{'date'} ne "")
    {
      if ($FORM{'date'} eq "Include Time & Date") { $DATE=`/bin/date +\'%B %d %Y %X\'`; }
      if ($FORM{'date'} eq "Include Date") { $DATE=`/bin/date +\'%B %d %Y\'`; }
      if ($FORM{'date'} eq "Include Time") { $DATE=`/bin/date +\'%X\'`; }
      if ($FORM{'date'} eq "Do Not Include Time Or Date") { $DATE=""; }
      chop $DATE;
      if ($DATE ne "") { $message = "[$DATE] : "; }
    }
    $message .= "$FORM{'message'} ";
    if ($FORM{'from'} ne "") { $message .= "- $FORM{'from'}"; }
    print "<P>\n<HR><P>\n";
    print "<B>To: </B> $FORM{'to'}<P>\n";
    print "<B>Message : </B>$message<P>\n";
    if ($debug)
    {
      $ret="/bin/echo \"$message\" | $pcmd";
      print "Command : $ret<P>\n";
      print "Date ($FORM{'date'}) : $DATE<P>\n";
    }
    else
    {
      { $ret=`/bin/echo \"$message\" | $pcmd`; }
    }
    print "<P>\n<HR><P>\n";
    &html_trailer();
  }
  else
  {
    if (! $debug) { &html_header("Page Error (Not Queued)"); }

    print "<P>\n<HR><P>\n";
    print "<H4>You left either the recipient, the sender, or the message body blank. All ";
    print "are required to actually send a page. Your page was NOT sent.\n";
    print "</H4><P>\n";
    print "<P>\n<HR><P>\n";

    &html_trailer();
  }

  exit 0;
}

sub html_header
{
  $DOCTITLE = $_[0];
  print "Content-type: text/html\n";
  print "\n";
  print "<HTML>\n";
  print "<HEAD>\n";
  print "<TITLE>$DOCTITLE</TITLE>\n";
  print "</HEAD>\n";
  print "<BODY>\n";
  print "<H1 ALIGN=CENTER>$DOCTITLE</H1>\n";
  print "<P>\n";
}

sub html_trailer
{
  print "</BODY>\n";
  print "</HTML>\n";
}


Thanks again.

Glacier
glacier101497Asked:
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.

aurelioCommented:
Hello glacier , I would like to know two things :
1) Which WWW server do you have (ncsa,apache or so)
2) Where is the sendpage.cgi script , so that we all could read it?
Depending on this information , surely I or somebody can answer your question.

Bye.
0
glacier101497Author Commented:
Edited text of question
0
glacier101497Author Commented:
Edited text of question
0
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

glacier101497Author Commented:
Points have been increased from 100 to 150, this is a pressing issue and would be great if I could get resolved today!

Thank you!

John
0
glacier101497Author Commented:
10/21/97 Points now increased from 150 to 200. I can add that one of the reasons I couldn't get this script to work is that I was working on it in MS Windows 95 Word Pad, then uploading it to my SunOS server. I found out that if the script isn't saved in Unix format, carriage return line feeds (CRLF's) may prevent the script from executing even if the syntax looks right. I still need help understanding how exactly to implement the script.

Thank you.

glacier
0
alamoCommented:
Ok, I'll take a crack at this. First let's review a basic assumption - this script is only an interface to the program "sendpage". If you don't have sendpage up and running so that you can send a page from the command line, stop right now and do that, working on the script is futile until then. To test sendpage to send a page to yourself for example you'd type:

sendpage glaciers-paging-id
blahblah Why isn't that paging script done yet? :)

susbstituting your pager id of course. Until this part works there is no point in continuing.

Near the start of the program there is a line $PROG = "/web/sendpage"; If sendpage isn't in the /web directory change this line so it points to the right place. Might as well set $debug=1 also.

In the HTML form which calls the script, there is a section:

 <SELECT NAME="to">
    <OPTION SELECTED>Primary User
    <OPTION>Group User
  </SELECT>

The basic script uses "Primary User" and "Group User" as placeholders. Change these to the person or persons you want to be pageable, for example:

 <SELECT NAME="to">
    <OPTION SELECTED>Bob
    <OPTION>Glacier
  </SELECT>

Add additional option lines if you want more than two people pageable. Now, in the script, you need to look for the options you placed in the HTML and use them to send the right page. Find the lines:

if ($FORM{'to'} eq "Group User") { $pcmd=$PROG . " groupid"; }
if ($FORM{'to'} eq "Primary User") { $pcmd=$PROG . " userid"; }

Change them to (using the example above for Bob and Glacier):

if ($FORM{'to'} eq "Bob") { $pcmd=$PROG . " Bobs-paging-id"; }
if ($FORM{'to'} eq "Glacier") { $pcmd=$PROG . " Glaciers-paging-id"; }

Substitute the apropriate paging ids. These need to be the values you used when you tested on the command line with sendpage.
0

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
glacier101497Author Commented:
Thanks for your reply Alamo. Now how do I get the 'sendpage' program to use with this script interface? I've done a meta search of the Web and found nothing.

Thanks.
0
alamoCommented:
I found a source distribution (it's written in C) at ftp://ftp.cs.unm.edu/pub/chris/paging/sendpage/ There are undoubtedly others, and maybe someone has already compiled it for your OS. There is information on the net on how to configure it.

The original distrubution point (at ohio state) appears to no longer exist.
0
glacier101497Author Commented:
I still have not been able to get this to work. One issue I specifically raised which was not addressed is how to deal with potential Carraige Return Line Feeds (CRLF's) between the PC and Unix platforms. Alamo told me what to do but not how. I know that CRLF's can cause a script to not work even if configuration changes are correct. This is a crucial step in debugging this script. Being a Perl script, does it have to be compiled after the changes? I'm green at this, but it also cost 200 points just to have someone look at this. I think more clarification is needed on this issue.

Thank you.

Glacier
0
alamoCommented:
Just us now, glacier - only you and I get to see this for free, everyone else has to pay 20 points each time.

"how to deal with CRLFs between PC and Unix"  - use Ascii mode ftp transfer, not Image (binary) ftp, and the ftp will translate them properly. If the perl script compiles without errors that's not the problem.

In perl the "compile" step is automatic every time you run the script, you do nothing special for it. The perl compiler reads the entire script and compiles it, looking for syntax errors. If it finds none then it immediately runs the compiled script. Any error it finds after that is a run-time error.
0
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
Scripting Languages

From novice to tech pro — start learning today.