<html><head><title></title></head><body>
Hi,
Currently,I am having a problem regarding the way to transfer the files across the server.
Before this,I am using the Net::FTP to transfer the files.But since,I am not the administrator of the server,I do not have the privilege to install the libnet on it.
So,I try another alternative way,which is using the UNIX and FTP command inside the perl script.
This is the script:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
use File::Copy;
$remotehost1 ="a";
$remotepath ="/b";
$remoteuser ="c";
$remotepass ="d";
@fileftp = qw(x.wml y.wml z.wml);
$cmd="ftp -n";
foreach $wmlfile (@fileftp)
{
if(-f $wmlfile)
{
$ftp_commands =
" open $remotehost1
user $remoteuser $remotepass
cd $remotepath
asc
put $wmlfile
bye
";
open (CMD, "|$cmd");
print CMD $ftp_commands;
close (CMD);
print "File $wmlfile has been transferred \n";
print "<br>\n";
$finish = 'transfer';
copy ("$wmlfile","./$finish/$wmlfile");
}
}
This script works fine,where
1.The file succeedly put inside the remotehost1 server.OK
2.The files @fileftp can be copied to 'transfer' folder.OK
except
Now I want to delete the files from @fileftp in the original folder in local host after I copy them to 'transfer'.
But ,when I insert another lines below the programs,which are
foreach $filefinish (@fileftp)
{
unlink $filefinish;
}
Then the 'Hell Breaks Loose'.What happened is
1.The files cannot be put inside the remote host server.KO.
2.The files from @fileftp can be copied from the local folder to 'transfer'.OK.
3.The files where I put the @fileftp in the first place,is deleted.(Above the 'transfer' directory).OK
After I execute it inside perl interpreter,it shows
C:\Perl\bin>perl file.pl
File x.wml has been transferred
<br>
File y.wml has been transferred
<br>
File z.wml has been transferred
<br>
x.wml: File not found
y.wml: File not found
z.wml: File not found
C:\perl\bin>
Please help me on this problem,since I have tried to solve it in many other different ways,but still stuck in the same place.I really really apreciate it if anyone can tell me what's wrong with it and how to solve it.Thank you in advance.
</body>
</html>
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.