Hello All,

I was trying to write this perl program and got stuck with it. Basically,
this program does the following

[1] Get the list of files from the dir that matches the file search
[2] Builds a string and calls another perl program (DBFTP.pl) which then
FTPs the file.
[3] Repeats [2] for each of the matching files .
[4] Does something else based on the completion of the FTP. If it is
successfull, it starts a uncompress
process, if it fails, it emails the admins. This step is yet to be
implemented.

The problem is that, the program loops thru the list of files and starts
the FTP process and exits. But this
wont tell me when the DBFTP.pl completes the FTP of all the files. For me
this is necessary because after
the successfull completion of the FTP of the files, I will have to start a
another process (Uncompress and
Restore process).

The documentation for Win32::Process is pretty vague, I think and I would
very much appreciate if someone
could help me with a sample script.

My question is :
[1] Even if I were to FTP just one file, how do I check the completion of
the process ?
[2] How do I repeat this for all the processes created ?
[3] What does Winn32::Process::Open($obj,$pid,$iflags) do ?

Thanks,
rgn

use File::Path;
use File::Basename;
use Win32;
use Win32::Process;

$ftpserver = " USFTPServer";
$uid = " upload";
$pwd = " upload";
$folder = " Cologne ";

@FTPFiles = glob("F:\\TAPEBACKUP\\401k.r*");

foreach $count(@FTPFiles) {

$putfile = $count;
$subject = " " .$count . "->FTPDone";
$logfile = outputfile($putfile,$putfile);
$cmdline = "Perl DBFTP.pl " . $putfile . $ftpserver . $uid . $pwd . $folder
. $logfile . $subject;
print "Command Line : $cmdline\n";

Win32::Process::Create($ProcessObj,
"D:\\ActivePerl\\bin\\Perl.exe",
$cmdline,
0,
DETACHED_PROCESS,
".") || die &print_error;

$ProcessObj->Wait(DETACHED_PROCESS) || warn &print_error;

$ProcessObj->GetExitCode($ExitCode) || warn &print_error;

print "Exit Code is : $ExitCode\n";
}

sub print_error {
print Win32::FormatMessage(Win32::GetLastError() );
}

sub outputfile {
($outputfile,$extension) = split(/\./,$putfile);
$outputfile = $outputfile . ".log";
return $outputfile;
}

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to