Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > ksh after perl script

Reply
Thread Tools

ksh after perl script

 
 
E Arredondo
Guest
Posts: n/a
 
      10-04-2005
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.


 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      10-04-2005
E Arredondo wrote:
> 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")


Put the shell program in a separate file, and then have the Perl
program execute that shell program, via the system() function.

system('/script/processupload');

perldoc -f system
for more information.

Paul Lalli

 
Reply With Quote
 
 
 
 
E Arredondo
Guest
Posts: n/a
 
      10-04-2005

"Paul Lalli" <> wrote in message
news: oups.com...
>E Arredondo wrote:
>> 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")

>
> Put the shell program in a separate file, and then have the Perl
> program execute that shell program, via the system() function.
>
> system('/script/processupload');
>
> perldoc -f system
> for more information.
>
> Paul Lalli
>


Thanks so much! It's now doing what I wanted!

When I do the perldoc -f system, it gives me a bunch of file errors, Do I
have to be a super user ?

# perldoc -f system
sh: nroff: not found
=over 8

=item system LIST

=item system PROGRAM LIST

Does exactly the same thing as C<exec LIST>, except that a fork is
done first, and the parent process waits for the child process to
complete. Note that argument processing varies depending on the
number of arguments. If there is more than one argument in LIST,
or if LIST is an array with more than one value, starts the program
given by the first element of the list with arguments given by the
rest of the list. If there is only one scalar argument, the argument
is checked for shell metacharacters, and if there are any, the
entire argument is passed to the system's command shell for parsing
(this is C</bin/sh -c> on Unix platforms, but varies on other
platforms). If there are no shell metacharacters in the argument,
it is split into words and passed directly to C<execvp>, which is
more efficient.

Beginning with v5.6.0, Perl will attempt to flush all files opened for
output before any operation that may do a fork, but this may not be
supported on some platforms (see L<perlport>). To be safe, you may need


/tmp/gtIwTGqkQn Can't open /tmp/Fz75XtwO8G for reading: No such file or
direct at /usr/bin/pod2man line 60



 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      10-04-2005
E Arredondo wrote:
> "Paul Lalli" <> wrote in message
> news: oups.com...
> > Put the shell program in a separate file, and then have the Perl
> > program execute that shell program, via the system() function.
> >
> > system('/script/processupload');
> >
> > perldoc -f system
> > for more information.
> >

> Thanks so much! It's now doing what I wanted!


You're welcome.

> When I do the perldoc -f system, it gives me a bunch of file errors, Do I
> have to be a super user ?
>
> # perldoc -f system
> sh: nroff: not found
> =over 8


<more POD snipped>

No. But you do have to get your local sysadmin to fix either your perl
installation or your nroff installation. In the meantime, consider
using the web interface to perldoc:
http://perldoc.perl.org
And just keep three translations in mind:
perldoc [something] ==> http://perldoc.perl.org/[something].html
perldoc -f [function] ==>
http://perldoc.perl.org/functions/[function].html
perldoc -q [phrase] ==> http://perldoc.perl.org/perlfaq.html (and
search for [phrase])

Paul Lalli

 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      10-04-2005
Paul Lalli <> wrote:
> E Arredondo wrote:
>> 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")

>
> Put the shell program in a separate file, and then have the Perl
> program execute that shell program, via the system() function.



Even better, since there is no more Perl needed after the ksh,
use the exec() function instead and save a whole process.


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      10-04-2005
Tad McClellan wrote:
> Paul Lalli <> wrote:
> > Put the shell program in a separate file, and then have the Perl
> > program execute that shell program, via the system() function.

>
>
> Even better, since there is no more Perl needed after the ksh,
> use the exec() function instead and save a whole process.


Ahh, I was wondering if I should have said exec() there instead of
system(), but I couldn't think of any particular reason for one over
the other. Thanks for pointing one out to me.

Paul Lalli

 
Reply With Quote
 
E Arredondo
Guest
Posts: n/a
 
      10-04-2005

"Tad McClellan" <> wrote in message
news:...
> Paul Lalli <> wrote:
>> E Arredondo wrote:
>>> 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")

>>
>> Put the shell program in a separate file, and then have the Perl
>> program execute that shell program, via the system() function.

>
>
> Even better, since there is no more Perl needed after the ksh,
> use the exec() function instead and save a whole process.
>
>
> --
> Tad McClellan SGML consulting
> Perl programming
> Fort Worth, Texas


Works too!, Thanks!


 
Reply With Quote
 
Tintin
Guest
Posts: n/a
 
      10-05-2005

"Tad McClellan" <> wrote in message
news:...
> Paul Lalli <> wrote:
>> E Arredondo wrote:
>>> 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")

>>
>> Put the shell program in a separate file, and then have the Perl
>> program execute that shell program, via the system() function.

>
>
> Even better, since there is no more Perl needed after the ksh,
> use the exec() function instead and save a whole process.


Or just convert the ksh script into Perl in the upload script.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie: perl program in a ksh here-document Jose Luis Perl Misc 3 08-13-2009 06:42 AM
separating substitutions from an embedded perl in a ksh script tazommers@yahoo.com Perl Misc 4 04-04-2008 07:23 PM
calling ksh script from python ronan_boisard@yahoo.com Python 12 06-08-2005 09:07 AM
how do I access ksh environment array variables in perl? Andy Haupt Perl Misc 1 03-24-2005 07:26 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments