CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Script treats character string as "cd" command

 



dlminton
Novice

Mar 4, 2010, 11:34 AM

Post #1 of 13 (1626 views)
Script treats character string as "cd" command Can't Post

Drop any amount of text into box, no problem, until you use the string "cd/" or "cd\" somewhere in the text, then the script returns an error.

See [http://dlmweb.com/perlTest/]

Go easy on me, I am a 62 yr old webbie, who has been using "baby talk" perl for years... but really only reusing a limited set of snippets that I know and can make work. I have built lots of content mangagement sites, however, and had thousands of pages built with my script variations, but never encountered this anomoly.


FishMonger
Veteran / Moderator

Mar 4, 2010, 12:21 PM

Post #2 of 13 (1619 views)
Re: [dlminton] Script treats character string as "cd" command [In reply to] Can't Post

Start by getting rid of this outdated code. (It's been out of date for more than 10 years and has a number of bugs)

Code
require "cgi-lib.pl"; 

# Read in variables

&ReadParse;

# Print out header

print &PrintHeader;


Replace it with this:

Code
use CGI; 

my $cgi = CGI->new;
my %in = $cgi->Vars;

print $cgi->header;



dlminton
Novice

Mar 4, 2010, 12:39 PM

Post #3 of 13 (1617 views)
Re: [FishMonger] Script treats character string as "cd" command [In reply to] Can't Post

ok, done. And thanks for that.

replaced code on test script, but its still has the same behavior (http://dlmweb.com/perlTest/)


FishMonger
Veteran / Moderator

Mar 4, 2010, 12:53 PM

Post #4 of 13 (1615 views)
Re: [dlminton] Script treats character string as "cd" command [In reply to] Can't Post

Can you post the full script?


dlminton
Novice

Mar 4, 2010, 1:02 PM

Post #5 of 13 (1612 views)
Re: [FishMonger] Script treats character string as "cd" command [In reply to] Can't Post

#!/usr/bin/perl

use CGI;

my $cgi = CGI->new;
my %in = $cgi->Vars;

print $cgi->header;


# The Program
&variables;

&createReturn;

sub variables {



$testData = $in{'testData'};


}

sub createReturn {

print <<Error;

$testData


Error






}


FishMonger
Veteran / Moderator

Mar 4, 2010, 1:18 PM

Post #6 of 13 (1607 views)
Re: [dlminton] Script treats character string as "cd" command [In reply to] Can't Post

Change the ENCTYPE to:

Quote
enctype="multipart/form-data"


And change the script to this:

Code
#!/usr/bin/perl 

use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $cgi = CGI->new;
my %in = $cgi->Vars;

print $cgi->header,
$cgi->start_html(-title => 'Test'),
$cgi->h1($in{'testData'}),
$cgi->end_html;



(This post was edited by FishMonger on Mar 4, 2010, 1:21 PM)


dlminton
Novice

Mar 4, 2010, 1:32 PM

Post #7 of 13 (1602 views)
Re: [FishMonger] Script treats character string as "cd" command [In reply to] Can't Post

changed the enctype on the input form, and replaced script w/new.

still same odd behavior, though.

Really appreciate this help, regardless of outcome!


FishMonger
Veteran / Moderator

Mar 4, 2010, 1:43 PM

Post #8 of 13 (1599 views)
Re: [dlminton] Script treats character string as "cd" command [In reply to] Can't Post

That's odd.

Lets try changing the script to this.

Code
#!/usr/bin/perl 

use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Data::Dumper;

my $cgi = CGI->new;
my %in = $cgi->Vars;

print $cgi->header,
$cgi->start_html(-title => 'Test'),
Dumper( \%in ),
$cgi->end_html;



dlminton
Novice

Mar 4, 2010, 1:54 PM

Post #9 of 13 (1597 views)
Re: [FishMonger] Script treats character string as "cd" command [In reply to] Can't Post

nope, still gives me this for the string "cd/"

Method Not Implemented

GET to /cgi-bin/perlTest.pl not supported.

for what it is worth using just the string "cd: gives me:

$VAR1 = { 'testData' => 'cd' };


FishMonger
Veteran / Moderator

Mar 4, 2010, 2:03 PM

Post #10 of 13 (1593 views)
Re: [dlminton] Script treats character string as "cd" command [In reply to] Can't Post

I just noticed that you're missing some quotes around a couple of the form attribute values. Some web servers have problems with unquoted values. Make sure each value is properly quoted.

If that doesn't solve the problem, then it's a web server issue and time to talk with your web host and see what they have to say.


dlminton
Novice

Mar 4, 2010, 2:10 PM

Post #11 of 13 (1590 views)
Re: [FishMonger] Script treats character string as "cd" command [In reply to] Can't Post

I will speak to my server guys, corrected the unquoted attributes to no avail.

Thank you so much for your help! At least I know it is a stubborn little quirk that has confounded a wiser hand than mine!!

BTW, My sites all run on pretty normal stuff...

Apache version 2.0.63

Perl version 5.8.8


dlminton
Novice

Mar 4, 2010, 3:26 PM

Post #12 of 13 (1581 views)
Re: [dlminton] Script treats character string as "cd" command [In reply to] Can't Post

As an interesting addendum to this (especially for the long term record) I just spoke to my son, who has a few sites he runs that are PHP driven. It seems this CD issue has similar problematic results on PHP content management systems. He raised the possibility that server settings themselves may be the "root" cause (no pun intended), and that other "system commands" are simply not possible.

Looks like the solution to this little issue is just for my music blogger to NOT use cd/dvd but rather the form dvd/cd. Of course, how it is that THIS forums input form and scripting doesn't choke on the cd/ remains an unanswered question.

Ah well, this afternoon's assistance from FishMonger has been marvelous, and serves to reinforce my decision of some 10 yrs ago that Perl is the right language for this old hippie!

Thks, FM
dlm


FishMonger
Veteran / Moderator

Mar 4, 2010, 3:35 PM

Post #13 of 13 (1579 views)
Re: [dlminton] Script treats character string as "cd" command [In reply to] Can't Post

Your form is still missing some quotes.

Change:

Code
<input type=text name="testData" size=50>


To:

Code
<input type="text" name="testData" size=50 />



(This post was edited by FishMonger on Mar 4, 2010, 3:36 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives