Solved

CGI Paging Script Configuration Issue

Posted on 1997-10-14
10
280 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
  • 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now