Solved

CGI Paging Script Configuration Issue

Posted on 1997-10-14
10
300 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:glacier101497
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 

Expert Comment

by:aurelio
ID: 1830799
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
 

Author Comment

by:glacier101497
ID: 1830800
Edited text of question
0
 

Author Comment

by:glacier101497
ID: 1830801
Edited text of question
0
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 

Author Comment

by:glacier101497
ID: 1830802
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
 

Author Comment

by:glacier101497
ID: 1830803
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
 
LVL 6

Accepted Solution

by:
alamo earned 200 total points
ID: 1830804
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
 

Author Comment

by:glacier101497
ID: 1830805
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
 
LVL 6

Expert Comment

by:alamo
ID: 1830806
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
 

Author Comment

by:glacier101497
ID: 1830807
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
 
LVL 6

Expert Comment

by:alamo
ID: 1830808
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

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question