E
E Arredondo
Hello, Please help me, I want to run a ksh script after a perl script on the
same cgi file, basically the perl is taking care of the uploading zip files
with photos from a website and then the korn shell uncompresses the received
files and moves them to their specific location and creates thumbnails, is
that possible ? Or maybe moving the ksh part of the script to a new file and
then making Perl execute it once it finishes with the first part . (i.e.
Perl execute "/script/processupload")
Here's how it gets run from a website : <FORM ACTION="/cgi-bin/upload.cgi"
METHOD="post" ENCTYPE="multipart/form-data">
Here's the actual script : upload.cgi
-------------------------------- start here -------------------
#!/usr/bin/perl -w
use CGI;
$upload_dir = "/www/docs/upload";
$query = new CGI;
$filename = $query->param("photo");
$claim = $query->param("claim");
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("photo");
open (UPLOADFILE, ">$upload_dir/$filename")
or die "Can't write to directory '$upload_dir/$filename': $~\n";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<END_HTML;
<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>
<BODY>
<P>Thanks for uploading your photo!</P>
</BODY>
</HTML>
END_HTML
#!/bin/ksh <<<<<<<<<<<<<----------------------here's what's next
umask 0
photos=/www/docs/domain.com/jpg/claims/
cd /www/docs/upload
setcase -lr /www/docs/upload > /dev/null 2>&1
ls *zip | while read line
do
typeset -i CLAIM1=`echo $line | cut -f1 -d.`
typeset -i folder=`expr $CLAIM1 / 500`
typeset -i claim=`expr $CLAIM1`
if [ $claim -gt "100000" ]
then
if [ ! -d $photos$folder/$claim ]
then
mkdir -p $photos$folder/$claim
fi
if [ -d $photos$folder/$claim ]
then
cd $photos$folder/$claim
unzip -oq /www/docs/upload/$line
setcase -lr $photos$folder/$claim > /dev/null 2>&1
for lone in !(*tnail*)
do
if [ ! -f "tnail$lone" ]
then
echo $lone
/usr/local/bin/djpeg $lone | /usr/local/bin/pnmscale 0.2 |
/usr/local/bin/cjpeg > tnail$lone
fi
done
rm -rf /www/docs/upload/$line
fi
fi
done
------------------ cut here -------------------------------------
Thanks.
same cgi file, basically the perl is taking care of the uploading zip files
with photos from a website and then the korn shell uncompresses the received
files and moves them to their specific location and creates thumbnails, is
that possible ? Or maybe moving the ksh part of the script to a new file and
then making Perl execute it once it finishes with the first part . (i.e.
Perl execute "/script/processupload")
Here's how it gets run from a website : <FORM ACTION="/cgi-bin/upload.cgi"
METHOD="post" ENCTYPE="multipart/form-data">
Here's the actual script : upload.cgi
-------------------------------- start here -------------------
#!/usr/bin/perl -w
use CGI;
$upload_dir = "/www/docs/upload";
$query = new CGI;
$filename = $query->param("photo");
$claim = $query->param("claim");
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("photo");
open (UPLOADFILE, ">$upload_dir/$filename")
or die "Can't write to directory '$upload_dir/$filename': $~\n";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<END_HTML;
<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>
<BODY>
<P>Thanks for uploading your photo!</P>
</BODY>
</HTML>
END_HTML
#!/bin/ksh <<<<<<<<<<<<<----------------------here's what's next
umask 0
photos=/www/docs/domain.com/jpg/claims/
cd /www/docs/upload
setcase -lr /www/docs/upload > /dev/null 2>&1
ls *zip | while read line
do
typeset -i CLAIM1=`echo $line | cut -f1 -d.`
typeset -i folder=`expr $CLAIM1 / 500`
typeset -i claim=`expr $CLAIM1`
if [ $claim -gt "100000" ]
then
if [ ! -d $photos$folder/$claim ]
then
mkdir -p $photos$folder/$claim
fi
if [ -d $photos$folder/$claim ]
then
cd $photos$folder/$claim
unzip -oq /www/docs/upload/$line
setcase -lr $photos$folder/$claim > /dev/null 2>&1
for lone in !(*tnail*)
do
if [ ! -f "tnail$lone" ]
then
echo $lone
/usr/local/bin/djpeg $lone | /usr/local/bin/pnmscale 0.2 |
/usr/local/bin/cjpeg > tnail$lone
fi
done
rm -rf /www/docs/upload/$line
fi
fi
done
------------------ cut here -------------------------------------
Thanks.