Phoenix.pm: holy buckets, batman!
Mark A. Sharkey
mark at wcws.com
Mon Dec 20 09:24:46 CST 1999
Tim,
Here's a quick script to simulate a command prompt that can run on hiway. Just
copy/paste into an editor, and upload to your hiway account. If my mail client
splits lines in inappropriate places, go to http://www.wcws.com/doit.txt for a
download copy. Name the file something like doit.cgi, and remember to chmod to
766 (or 777):
P.S. Critiques on the code are welcome.
#!/usr/bin/perl
#
# doit.cgi - shell emulator
#
# to be installed in a secure directory immediately off the root
#
#### Turn off perl's buffer so browser won't time out ####
$| = 1;
#### Do standard HTTP stuff ####
&cgi_receive;
&cgi_decode;
&htm_header;
# user may need to change or eliminate this next line
chdir "../";
system ("$FORM{'command'} 2>&1") if ($FORM{'command'});
&htm_footer;
exit;
#####################################################################
#### SUBROUTINES ####################################################
#----------------------------------------------------------------------
sub cgi_receive {
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $incoming, $ENV{'CONTENT_LENGTH'});
}
else {
$incoming = $ENV{'QUERY_STRING'};
}
}
#----------------------------------------------------------------------
sub cgi_decode {
@pairs = split(/&/, $incoming);
foreach (@pairs) {
($name, $value) = split(/=/, $_);
$name =~ tr/+/ /;
$value =~ tr/+/ /;
$name =~ s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/gie;
$value =~ s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/gie;
#### Strip out semicolons unless for special character
$value =~ s/;/$$/g;
$value =~ s/&(\S{1,6})$$/&\1;/g;
$value =~ s/$$/ /g;
$value =~ s/\|/ /g;
$value =~ s/^!/ /g; ## Allow exclamation points in sentences
#### Skip generally blank fields
next if ($value eq "");
#### Allow for multiple values of a single name
$FORM{$name} .= ", " if ($FORM{$name});
$FORM{$name} .= $value;
#### Add to ordered list if not on list already
push (@fields, $name) unless (grep(/^$name$/, @fields));
}
}
#----------------------------------------------------------------------
sub htm_header {
print qq|Content-type: text/html
<html>
<head>
<title>Command Entry</title>
</head>
<body bgcolor=white onLoad="document.form1.command.focus();">
<h2 align=center>Command Entry</h2>
<hr>
<div align=center>
<form method=get action=doit.cgi name=form1>
<input type=text name=command value="$FORM{'command'}" size=50><br>
<input type=submit value="Do It!"> <small>(Or hit Enter to submit)</small>
</form>
</div>
<hr>
<pre>
|;
}
#----------------------------------------------------------------------
sub htm_footer {
print qq|</pre>
</body>
</html>
|;
}
Beaves at aol.com wrote:
>
> Thanks, Doug for pointing me in the 'Storable.pm' direction and to finally
> use the Active State ppm for installing my modules. (That is pretty neat
> stuff!!)
>
> However, I have run into a slight problem. Storable.pm works fine at home on
> my Win95 machine. Since I can't do shell work with my ISP (Hiway.com), I
> figured I'd just FTP all the files that the .ppm provided. When I try to run
> my script from the server, Storable is not working. It uses AutoLoader and
> DynaLoader, and DynaLoader is crashing when it looks for the .dll file (near
> as I can tell) for Storable. (Confused yet?) I can't say for certain, but
> I'd bet that because of the platform differences, I can't just FTP my PC
> files and think that everything will be hunky dory on my server which runs
> UNIX. (Like I said, the module works with no hitches on my PC).
>
> Soooo, where does that leave me without a paddle? Well, there are two
> solutions that I have yet to try, (and I've tried quite a few already...)
> First, I would not mind in the least writing a program that simulated a shell
> script, or one that mimicked the
> "
> perl Makefile.PL;
> make
> make install
> "
> stuff. But can I simulate a shell from a Perl script? How?
>
> Second solution is to have someone working in UNIX that might have a
> (working) copy of the Storable.pm module and its auto loading subdirectories.
> I could just FTP the correct (hopefully) stuff. 'Maybe' that will work.
>
> Changing ISP's is more and more enticing...
> Thanks to anyone that listened for listening...
>
> Tim
--
Have questions about iServer?
Join the mailing list created for iServer webmasters
at http://www.providertalk.com
@--------------------------- at -----------------------@
| Mark A. Sharkey | mailto:mark at wcws.com |
| World Class Web Sites | http://www.wcws.com |
| | 800 844 4434 |
| Custom CGI Scripts | 480 461 9765 |
| Perl PHP MySQL JavaScript | 480 461 9312 (fax) |
@--------------------------- at -----------------------@
More information about the Phoenix-pm
mailing list