join these two scripts

i have two scripts....
first one puts a file from a computer onto my server
second one lets the user characterise each word in the file they just uploaded......

i include the code below but want to know if this is possible
where it says
"thanks we appreciate the upload of....."
i would like it to automatically start the second script
and open the file that was just uploaded and
continue with the second script

so when someone uploads a file the next thing they see is that file with the drop down menus after each word

both scripts work fine its just that i dont know how to combine them in the way i want


===========sript one================

#!/usr/local/bin/perl
#scipt uploads files to specified dir in the
#format daydaymonthmonthyearyearyearyearuniquenumber.txt

use lib "/usr/local/depot/perl5.005_02/lib/5.00502";

      use CGI;
      use CGI::Carp 'fatalsToBrowser';

      $myCGI = new CGI;
      $outputPath = "/data/local/apache/htdocs/answers";

      print $myCGI->header, $myCGI->start_html;

      if (!$myCGI->param('fileName')) {

         print $myCGI->p("Sorry, your submission didn't include an upload.");

      }
      else {
          $myFileStream = $myCGI->param('fileName');

          ($barefilename) = $myFileStream =~ /.*[:\/\\](.*)/;
          $barefilename = $myFileStream unless $barefilename;

          binmode $myFileStream;

use Fcntl;
      ($d,$m,$y)=(localtime)[3,4,5];
      $m+=1; $y+=1900;
      $date=sprintf("%02d%02d%04d",$d,$m,$y);
      $count=0;
      do{
        $count++;
      }until(  sysopen(OUTFILE,"$outputPath/$date$count.txt",O_WRONLY|O_EXCL|O_C
REAT) || $!
      ne "File exists" );
      defined(fileno(OUTFILE)) || die "Can't create $outputPath/$date$count.txt:
 $!";

          binmode OUTFILE;
          while (<$myFileStream>) {
             print OUTFILE;
          }
          close OUTFILE;
          close $myFileStream;
          print $myCGI->p("Thanks.  We appreciate your upload of $barefilename."
);
      }
  print $myCGI->end_html;

      undef $myCGI;

========================


=============script two=============

#!/usr/local/bin/perl
#this script opens a file and places a drop down #menu after each word in the file
#users can then classify each word in the file
#ie say if each word is good bad or ok
#results are placed into a unique file
#in the format
#this ok
#is good
#a bad
#test ok
use lib "/usr/local/depot/perl5.005_02/lib/5.00502";
use CGI qw/:standard/;
use CGI::Carp 'fatalsToBrowser';

$outputPath = "/data/local/apache/htdocs/answers";

print header, start_html('set answers');
                open FILE,'<story.txt' or die "can't open story.txt because $!";

                if( param ){
                        print "<br><br><center>Thanks for setting the test<br><b
r>";
use Fcntl;
                        ($d,$m,$y)=(localtime)[3,4,5];
                        $m+=1; $y+=1900;
                        $date=sprintf("%02d%02d%04d",$d,$m,$y);
                        $count=0;
                        do{
                          $count++;
                        }until(  sysopen(CORRECT,"$outputPath/$date$count.txt",O
_WRONLY|O_EXCL|O_CREAT) || $! ne
                        "File exists" );
                        defined(fileno(CORRECT)) || die "Can't create $outputPat
h/$date$count.txt: $!";

                        while( <FILE> ){
                            while( /(\w+)/g ){
                                print CORRECT "$1 ",(param $1)[$count{$1}++],"\n
";
                            }
                        }
                        close CORRECT;
                }else{
                        print start_form;
                        while( <FILE> ){
                                s/(\w+)/"$1".popup_menu(-name=>"$1",-values=>[(good,bad,ok)])/eg;
                                print;
                       }
                       close FILE;
  print submit, end_form;
                }
      print end_html;
====================
paulwhelanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

paulwhelanAuthor Commented:
can someone repost the joined working script?
0
ozoCommented:
#!/usr/local/bin/perl
#scipt uploads files to specified dir in the
#format daydaymonthmonthyearyearyearyearuniquenumber.txt

use lib "/usr/local/depot/perl5.005_02/lib/5.00502";

      use CGI;
      use CGI::Carp 'fatalsToBrowser';

      $myCGI = new CGI;
      $outputPath = "/data/local/apache/htdocs/answers";
      $outputPath = ".";

      print $myCGI->header, $myCGI->start_html;

      if (!$myCGI->param('fileName')) {

         print $myCGI->p("Sorry, your submission didn't include an upload.");

      }
      else {
          $myFileStream = $myCGI->param('fileName');

          ($barefilename) = $myFileStream =~ /.*[:\/\\](.*)/;
          $barefilename = $myFileStream unless $barefilename;

          binmode $myFileStream;

use Fcntl;
      ($d,$m,$y)=(localtime)[3,4,5];
      $m+=1; $y+=1900;
      $date=sprintf("%02d%02d%04d",$d,$m,$y);
      $count=0;
      do{
        $count++;
      }until(  sysopen(OUTFILE,"$outputPath/$date$count.txt",O_WRONLY|O_EXCL|O_CREAT) || $!
      ne "File exists" );
      defined(fileno(OUTFILE)) || die "Can't create $outputPath/$date$count.txt:
 $!";

          binmode OUTFILE;
          while (<$myFileStream>) {
             print OUTFILE;
          }
          close OUTFILE;
          close $myFileStream;
          print $myCGI->p("Thanks.  We appreciate your upload of $barefilename."
);
          &two;
      }
  print $myCGI->end_html;

      undef $myCGI;

sub two{
#!/usr/local/bin/perl
#this script opens a file and places a drop down #menu after each word in the file
#users can then classify each word in the file
#ie say if each word is good bad or ok
#results are placed into a unique file
#in the format
#this ok
#is good
#a bad
#test ok
#use lib "/usr/local/depot/perl5.005_02/lib/5.00502";
#use CGI qw/:standard/;
#use CGI::Carp 'fatalsToBrowser';

#$outputPath = "/data/local/apache/htdocs/answers";

#print header, start_html('set answers');
                open FILE,'<story.txt' or die "can't open story.txt because $!";

                if( $myCGI->param ){
                        print "<br><br><center>Thanks for setting the test<br><br>";
use Fcntl;
                        ($d,$m,$y)=(localtime)[3,4,5];
                        $m+=1; $y+=1900;
                        $date=sprintf("%02d%02d%04d",$d,$m,$y);
                        $count=0;
                        do{
                          $count++;
                        }until(  sysopen(CORRECT,"$outputPath/$date$count.txt",O_WRONLY|O_EXCL|O_CREAT) || $! ne
                        "File exists" );
                        defined(fileno(CORRECT)) || die "Can't create $outputPath/$date$count.txt: $!";

                        while( <FILE> ){
                            while( /(\w+)/g ){
                                print CORRECT "$1 ",($myCGI->param($1))[$count{$1}++],"\n";
                            }
                        }
                        close CORRECT;
                }else{
                        print $myCGI->start_form;
                        while( <FILE> ){
                                s/(\w+)/"$1".$myCGI->popup_menu(-name=>"$1",-values=>[(good,bad,ok)])/eg;
                                print;
                       }
                       close FILE;
  print $myCGI->submit, $myCGI->end_form;
                }
#      print end_html;
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
paulwhelanAuthor Commented:
i think i got too confused there.....

heres what id like it to do

first people can upload a file and this
isnt placed onto the server. what happens is a
dropdown menu is placed after every word
in that file

then the file that is placed onto the server has a unique id and contains the words and the classifications.....

so if i upload test.txt which contains the text
"this is a test" i click to send the file
and the next screen i get has
this [click here] is [click here] a [click here] test [click here]
then when i classify the words and unique file is opened (ie 021219991.txt for the first file opened on the 2nd of dec 1999) and that file contains
something like this
this ok
is ok
a bad
test good

thats all i want it to do
heres the html i use to call the cgi

  <form action="http://myserver/cgi-bin/uploadandtest.cgi" method="po
st" enctype="multipart/form-data">
      <input type="file" name="fileName"><BR>
      <input type="submit" value="Send File">
      </form>

can someone post what uploadandtest.cgi should look like?
thanks for you help ozo
ozo when i tried to run what u posted it
said that it couldnt create the unique id file
(and i did chmod 777 on the relevant dir)
thanks
paul

0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

paulwhelanAuthor Commented:
ozo
i got the permissions right now
but when i click send file
it says "thanks for setting the test"
but i never even got a chance to set the test
paul
0
spiegeiCommented:
I would do this with a libarary .pm file. Set up the second script to be a fucnction and put it in a file with a .pm extension.
(example: dropdown.pm) and place similar code as below around it.
Step 1:

package dropdown;
require Exporter;
@ISA =qw{Exporter};
@EXPORT=qw{dropdown};


sub dropdown {

 
 your code from second script here
}


Step 2:

In your first script at the top make a reference to this pm file with the correct path to it.
example use dropdown.pm     or use ../library/dropdown.pm


Step3:
Call the second script in the .pm from the first script by just calling the function
dropdown();
0
paulwhelanAuthor Commented:
i think it would be best if someone could post working code that does this

heres what i want it to do again

users upload a file when they hit "send file" the next thing
they see is the file they just uploaded with a dropdown menu (options are "good" "bad" and "ok") after every word in that file
 
then at the end of the page with all the words and dropdown menus there is a submit button....
when they click this button a unique file is opened
and the results of setting the test are in there


so if i upload test.txt which contains the text
"this is a test" i click to send the file
and the next screen i get has
this [click here] is [click here] a [click here] test [click here]
then when i classify the words and hit submit a unique file is opened (ie 021219991.txt for the first file opened on the
2nd of dec 1999) and that file contains
something like this
                this ok
                is ok
                a bad
                test good

                thats all i want it to do
                heres the html i use to call the cgi

                  <form action="http://myserver/cgi-bin/uploadandtest.cgi" method="po
                st" enctype="multipart/form-data">
                      <input type="file" name="fileName"><BR>
                      <input type="submit" value="Send File">
                      </form>

                can someone post what uploadandtest.cgi should look like?

thanks for you help

                paul
0
paulwhelanAuthor Commented:
spiegei u shouldnt answer questions
just put your answer as a comment my points are
lost now and i worked out the answer myself
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.