I wish to begin by, thanking each and everyone for your helpful comments.  

The situation looks more in detail liks so:  The clients are all in remote
areas - they aren't part of our network;  They (as I stated before) are
runnign WinNT wks.  Each has a version of ActivePerl running (AP522).  They
will be attaching to our network, with VPN, using Dial-up Networking.

Over a period of 2-3 weeks, these remote clients work on an application (a
series of Excel workbooks), and enter data in them.  At some point, this
Excel workbooks generate a group of files with collected, crunched and
summarized data that needs to be send over to our network, for processing
(the files aren't too large but, they are important).  Collecting these
pieces of information can take several days, as the remote users don't enter
the data all at once, and it will arrive as they (remote users) get to
complete their tasks (on their own time).  That is why an "AT" (or "Task
Scheduler" as its now known) job is out of the question as, nothing
guarantees that the file(s) will be ready by the time the scheduled task
runs.

My original instinct was to:  Write a Perl script that sends the files via
FTP (piece of cake!).  Then, create a shortcut on their desktop and, have
the user "double-click" on it, when the information is ready.  But, the new
head of my department is asking that this whole process be web-browser
driven...that is, a web page be used to start the application.  
Why?  I don't know... Honestly, I don't see the benefits from doing so but,
for learning benefits and the challenge of doing it, is that I picked up the
ball, so to speak.

So I though that, since I already have Perl on all the clients, I could
insert the Net::FTP code into a webpage and have it send the files over
here.  To be honest, my knowledge on HTML has been that of a hobbyst (more
than a profesional at it) level.  So, I guess I should have been more direct
and state that, I wanted some direction on a Perlscript-based webpage, to do
just what we want.

For now, I came up with something like this: (ugly, for my taste)

  <html>
  <head>
  <title>Send Files</title>
  </head>
  <body>
  <p>To send files, <a href="file://c:/sendfiles/sendfiles.pl">click
here</a></p>
  </body>
  </html>

This, is a page that has a link to a perl script (located in the \SendFiles
directory of the C: drive  of the client's PC).  I really don't like it, as
I have to modify a whole bunch of browsers, to avoid the prompt to "download
or open and run" dialog.

I imagined that a Perlscript routine embedded into a page, and then
triggered by a hyperlink or a form button, would do the trick:

(The next routine, is practically the same 'sendfiles.pl' mentioned above,
but without any 'print' statements, as they don't work on browsers)

  <script language=Perlscript>
  sub SendFiles {
    use Net::FTP;
    
    # config.dat has our identifier: a number between "01" and "90"
    $config = "C:\\SENDFILES\\CONFIG.DAT";
    open (IN, "<$config");
    $unit_number = <IN>;
    close $config;
    
    $ftp_server = "10.0.0.1";
    $usr = "anonymous";
    $pwd = "user" . $unit_number . "\@xyz.com";
    $export_path = "C:\\EXPORT";
    $destination  = "\\USER_" . $unit_number . "\\IMPORT";
    $debug_mode = 1;
    
    opendir(DIR, "$export_path") or die;
    @files_to_export = grep (!/^\./, readdir(DIR));
    closedir (DIR);
    
    # Connect to the FTP server and log in.
    $ftp = Net::FTP->new($ftp_server, Debug=>$debug_mode) or die 
    
    $ftp->login($usr, $pwd);
    $ftp->binary;
        
    $ftp->cwd("$destination");
    chdir $export_path;
        
    # delete any existing file(s) in the target destination...
    my (@files) = $ftp->ls("*.*");
    foreach my $file (@files) { $ftp->delete($file); }
    
    # Now, send all the files, to the server...
    foreach my $file (@files_to_export) { $ftp->put($_); }

    # Good bye.
    $ftp->quit;
  }
  </script>
  
  
Again, I though that a form button or a hyperlink, the user could invoke
this routine (or something similar).  The problem is that, I tried it but it
doesn't work.

I welcome any suggestions/comments and (again), I thank you all for your
participation in my little problem...


-Carl


-----Original Message-----
From: scott [gts] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 20, 2001 8:01 AM
To: perl
Subject: RE: File Transfer / Client-side Perlscript / How?


relying on users to make a "simple click" is *never*
as simple as that ;)  people forget.

personally, i would opt for the scheduling of a cron-like
script in windows, then use Net::FTP to xfer the files.

as far as i know, even if the user is logged out, the
scheduler will still run the script. (so you can set 
it to do all the work at 2:00am, for example, and not
bog down the network during working hours)

one other thing... you should try and zip/tar/compress
the files before transferring, to conserve network bandwidth.

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Lee
> Goddard
> Sent: Wednesday, June 20, 2001 5:52 AM
> To: Carl Campbell; [EMAIL PROTECTED]
> Subject: RE: File Transfer / Client-side Perlscript / How?
> 
> 
> > I'm working on an web-based project and I'm facing a challenging
situation.
> > 
> > I have been asked to come up with a way to transfer a bunch of files,
> > located in a certain folder of our client's workstations, to our FTP
server,
> > so we can process them at the end of the business cycle.  The trick here
is
> > that, (my employer) wants this action to occur with NO USER
INTERVENTION.
> > Or limited to a single click, to be more precise.
> > 
> > The client PCs have Perl installed (with libwww) in them (for
administration
> > purposes) and all run WinNT Wks (if is relevant).
> > 
> > I am really not asking people to write the code for me.  But, I'll be
honest
> > here:  I don't have a clue on how to start.  is this possible?  I've
never
> > seeing this sort of thing before:  Where a web browser initiates a
transfer
> > of files, to a foreign server.  Is a client-side PerlScript-embedded
HTML
> > page possible?
> 
> Don't worry: you could find loads of examples of this.
> 
> You could have the clients run a script at an icon-click (or using the
> Windows cron-equiv for which someone here can give you the module details)
> to use the client's libwww's FTP, or use Net::FTP to upload to the FTP
> server.  Or you could have one machine acting as a server to access each
of
> the user machines, and put the info to the FTP server. I'd do the latter,
> simply because it'd be less to maintain (and no matter what the boss says,
> he'll want it maintain and added to).
> 
> hth
> lee
> _______________________________________________
> Perl-Win32-Web mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web
> 
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to