Sponsored Content
Full Discussion: Pearl Script Help
Top Forums UNIX for Advanced & Expert Users Pearl Script Help Post 69969 by nikah_01 on Saturday 23rd of April 2005 05:24:07 PM
Old 04-23-2005
Pearl Script Help

Code:
#!/usr/bin/perl


$basedir = "/home/MYUSERID/public_html/ordered_files";
$allowall = "yes";
$theext = ".gif";

use CGI;
 
$onnum = 1;

while ($onnum != 11) {
my $req = new CGI; 
my $file = $req->param("FILE$onnum"); 
if ($file ne "") {
my $fileName = $file; 
$fileName =~ s!^.*(\\|\/)!!; 
$newmain = $fileName;
if ($allowall ne "yes") {
if (lc(substr($newmain,length($newmain) - 4,4)) ne $theext){
$filenotgood = "yes";
}
}
if ($filenotgood ne "yes") { 
open (OUTFILE, ">$basedir/$fileName"); 
print "$basedir/$fileName<br>";
while (my $bytesread = read($file, my $buffer, 1024)) { 
print OUTFILE $buffer; 
} 
close (OUTFILE); 
}
}
$onnum++;
}


my $sendmail = "/usr/sbin/sendmail";

# A text file containing a list of valid email recipients and the web pages to 
# which the user should be redirected after email is sent to each, on 
# alternating lines.  This allows one copy of the script to serve multiple 
# purposes without the risk that the script will be abused to send spam.
# YOU MUST CREATE SUCH A TEXT FILE AND CHANGE THE NEXT LINE TO ITS
# LOCATION ON THE SERVER.

my $emailConfPath = "http://www.MEWEBSITE.com/emailman/email.conf";

# Parse any submitted form fields and return an object we can use
# to retrieve them
my $query = new CGI;

my $project = &clean($query->param('project'));
my $name = &clean($query->param('name'));
my $number = &clean($query->param('number'));
my $address = &clean($query->param('address'));
my $address2 = &clean($query->param('address2'));
my $citystate = &clean($query->param('citystate'));
my $sizing = &clean($query->param('sizing'));
my $comments = &clean($query->param('comments'));
my $subject = &clean($query->param('subject'));
my $file1 = &clean($query->param('file1'));
my $file2 = &clean($query->param('file2'));
my $text = &clean($query->param('text'));
my $font = &clean($query->param('font'));
my $dropshadow = &clean($query->param('dropshadow'));
my $textcolor = &clean($query->param('textcolor'));
my $shadowcolor = &clean($query->param('shadowcolor'));


#Note: subject is not mandatory, but you can easily change that
if (($project eq "") || (($name eq "") || ($number eq "") || ($address eq "") || ($citystate eq "") || ($sizing eq ""))
{
	&error("Requist Denied",
		"You must fill out all of the required fields." .
		"Please Try Again.");
}

if (!open(IN, "$emailConfPath")) {
	&error("Configuration Error",
		"The Configuration file is missing or corrupt" .
		"please repair the file.");
	my $ok = 0;
	while (1) {
		my $recipientc = <IN>;
		if ($recipientc eq "") {
			last;
		}
		my $returnpage = <IN>;
		if ($returnpage eq "") {
			last;
		}
		if ($recipientc eq $recipient) {
			$ok = 1;
			last;
		}
	}
	close(IN);
	if (!$ok) {
		&error("Email Rejected",
			"You are unable to submit a file at this time try e-mailing this form to :" .
			"user@MEWEBSITE.com to get your order in." .
			"You also may note that there is a problem with this form on the site.");
	}
	# Open a pipe to the sendmail program
	open(OUT, "|$sendmail -t");
	print OUT <<EOM
To: $recipient
Subject: $subject
Project Name:       $project
Customers Name:     $name 
Customers Phone:    $number 
Address:            $address 
                    $address2 
City/State/Zip:     $citystate 
Sizing:             $sizing
Files:              $file1
                    $file2
Lettering Text:     $text
Font for Lettering: $font
Drop Shadow:        $dropshadow
Text Color:         $textcolor
Shadow Color:       $shadowcolor
Additional Notes:   $comments

EOM
;
	close(OUT);
	# Now redirect to the appropriate "landing" page for this recipient.
	print $query->redirect($returnPage);
}

sub clean
{

	my $s = shift @_;
	$s =~ s/^\s+//;
	$s =~ s/\s+$//;
	return $s;
}

sub error
{
	my($title, $content) = @_;
	print $query->header;
	print <<EOM
<html>
<head>
<title>$title</title>
</head>
<body>
<h1 align="center">$title</h1>
<p>
$content
</p>
EOM
;
	exit 0;
}


Last edited by nikah_01; 04-23-2005 at 10:15 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

pearl

Sir, I am in doubt using pearl can i create exe files in pearl. Also is there a pearl compiller.I am new to pearl and please suggest how can i learn pearl arun (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

2. Shell Programming and Scripting

how to log if the program contains both bourne-shell & pearl scripts

I have a program (say, MyProgram) written in Bourne-shell script, but at some point it calls another script written in pearl, as illustrated below: #!/bin/sh ..... case $x in 1) ConfigSystem1 ( b-shell script) 2) ConfigSystem2 ( pl) 3) ConfigSystem3 (b-shell) .... Then I create... (0 Replies)
Discussion started by: bluemoon1
0 Replies

3. UNIX for Advanced & Expert Users

Pearl script to automate SSL certificate import

Hello, I want to automate the process of importing a SSL certificate name *.cer to cacerts through perl script. both the certificates belong to same folder. The usual way of doing it is by executing the below command which imports the key name certnew.cer to cacerts in the same folder. ... (4 Replies)
Discussion started by: m_kk
4 Replies

4. Shell Programming and Scripting

c function calling from a pearl script

Hi, Is it possible to call a c function defined in a .c file from a pearl script? How is this possible? Thannks in advance, JS (2 Replies)
Discussion started by: jisha
2 Replies

5. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

6. UNIX for Dummies Questions & Answers

Pearl,Unix systems Commands

hi does anyone have any knowledge of pearl, unix systems commmands and what are the basic commands??????apppreciated for your help. (1 Reply)
Discussion started by: BIzzare12
1 Replies

7. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

8. UNIX for Dummies Questions & Answers

Pearl script Net::SFTP authentication error

#!/usr/local/bin/perl -w use Net::SFTP; use File::Copy; my $user=(getpwuid($<)); my $server = "servername"; print "user - $user server - $server \n"; my %args = ( user => "$user", ssh_args => {port=> 'portnum'} ); $args{debug} = 1; $args{user} = "user"; my $sftp=Net::SFTP->new($server,... (1 Reply)
Discussion started by: Yashaswini H L
1 Replies

9. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies
All times are GMT -4. The time now is 11:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy