ksh after perl script

Discussion in 'Perl Misc' started by E Arredondo, Oct 4, 2005.

  1. E Arredondo

    E Arredondo Guest

    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.
    E Arredondo, Oct 4, 2005
    #1
    1. Advertising

  2. E Arredondo

    Paul Lalli Guest

    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
    Paul Lalli, Oct 4, 2005
    #2
    1. Advertising

  3. E Arredondo

    E Arredondo Guest

    "Paul Lalli" <> wrote in message
    news:...
    >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
    E Arredondo, Oct 4, 2005
    #3
  4. E Arredondo

    Paul Lalli Guest

    E Arredondo wrote:
    > "Paul Lalli" <> wrote in message
    > news:...
    > > 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
    Paul Lalli, Oct 4, 2005
    #4
  5. 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
    Tad McClellan, Oct 4, 2005
    #5
  6. E Arredondo

    Paul Lalli Guest

    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
    Paul Lalli, Oct 4, 2005
    #6
  7. E Arredondo

    E Arredondo Guest

    "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!
    E Arredondo, Oct 4, 2005
    #7
  8. E Arredondo

    Tintin Guest

    "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.
    Tintin, Oct 5, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kaeli
    Replies:
    8
    Views:
    1,377
    Harald Kirsch
    Feb 13, 2004
  2. Replies:
    12
    Views:
    2,423
    Magnus Lycka
    Jun 8, 2005
  3. Andy Haupt
    Replies:
    1
    Views:
    117
    Chris Mattern
    Mar 24, 2005
  4. Replies:
    4
    Views:
    110
    Ben Morrow
    Apr 4, 2008
  5. Jose Luis
    Replies:
    3
    Views:
    159
    Jose Luis
    Aug 13, 2009
Loading...

Share This Page