[Ilugc] Perl Net::FTp

  • From: Pravinkumar_Shivakumar@xxxxxxxxxx (Pravinkumar_Shivakumar)
  • Date: Sat, 10 Aug 2002 10:13:15 +0530

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

--------------InterScan_NT_MIME_Boundary
Content-Type: multipart/alternative;
        boundary="----_=_NextPart_001_01C24028.70AB9E00"


------_=_NextPart_001_01C24028.70AB9E00
Content-Type: text/plain;
        charset="iso-8859-1"

Hi Imthiaz,
 
Check the mode ur using to transfer the file.
change to Binary and give it a shot....
1) $ftp->type('A'); #Change to ASCII mode for Data Transfer

2) $ftp->type('I'); #Change to Binary mode for Data Transfer

 
HTH,
Pravin Kumar S

-----Original Message-----
From: Imthiaz Rafiq [mailto:imthiazrafiq@xxxxxxx]
Sent: Saturday, August 10, 2002 9:22 AM
To: LUG Chennai
Subject: [Ilugc] Perl Net::FTp


I am doing a ftp downloading script in perl. The script runs properly. But
the downloaded file des.zip was curupted. Do you have any idea what is that.
Please tell me
 

#!/usr/bin/perl
 
use Net::FTP;
 
my $ftp = Net::FTP->new(" ftp.asksathia.com",Debug <ftp://ftp.asksathia.com>
=> 0); 
$ftp->login("asksathia","allowme"); 
$ftp->cwd("/htdocs"); 
$ftp->get("des.zip"); 
my $stat = $ftp->status; 
my $full_stat = $ftp->code; 
# $stat contains the first digit; usually all 
# that you need to do is test if it is equal 
# to 2. $full_stat contains the full 3-digit 
# value but is seldom needed 
printf("Status: %d Full Status: %d\n",$stat,$full_stat); 
# Sample Test 
if ($stat == 2) 

    print "Get was OK\n"; 

else 

    print "Get was BAD\n"; 

$ftp->quit;

Thanks 
Imthiaz

************************************************************************** 
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************

------_=_NextPart_001_01C24028.70AB9E00
Content-Type: text/html;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">


<META content=3D"MSHTML 6.00.2462.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><SPAN class=3D804262904-10082002><FONT face=3DArial =
color=3D#0000ff size=3D2>Hi=20
Imthiaz,</FONT></SPAN></DIV>
<DIV><SPAN class=3D804262904-10082002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2>&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=3D804262904-10082002><FONT face=3DArial =
color=3D#0000ff size=3D2>Check=20
the mode ur using to transfer the file.</FONT></SPAN></DIV>
<DIV><SPAN class=3D804262904-10082002><FONT face=3DArial =
color=3D#0000ff size=3D2>change=20
to Binary and give it a shot....</FONT></SPAN></DIV>
<DIV><SPAN class=3D804262904-10082002><FONT color=3D#0000ff size=3D2>
<P><FONT face=3DArial>1) <B><I>$ftp-&gt;type('A');</B></FONT></I><FONT =
face=3DArial>=20
#Change to ASCII mode for Data Transfer</FONT></P>
<P><FONT face=3DArial>2) <B><I>$ftp-&gt;type('I');</B></FONT></I><FONT =
face=3DArial>=20
#Change to Binary mode for Data =
Transfer</FONT></P></FONT>&nbsp;</SPAN></DIV>
<DIV><SPAN class=3D804262904-10082002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2>HTH,</FONT></SPAN></DIV>
<DIV><SPAN class=3D804262904-10082002></SPAN><SPAN =
class=3D804262904-10082002><FONT=20
face=3DArial color=3D#0000ff size=3D2>Pravin Kumar =
S</FONT></SPAN></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> Imthiaz Rafiq=20
  [mailto:imthiazrafiq@xxxxxxx]<BR><B>Sent:</B> Saturday, August 10, =
2002 9:22=20
  AM<BR><B>To:</B> LUG Chennai<BR><B>Subject:</B> [Ilugc] Perl=20
  Net::FTp<BR><BR></FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>I am doing a ftp downloading script =
in perl. The=20
  script runs properly. But the downloaded file des.zip&nbsp;was =
curupted. Do=20
  you have any idea what is that. Please tell me</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
    <DIV><FONT face=3DArial size=3D2>#!/usr/bin/perl</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>use Net::FTP;</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>my $ftp =3D Net::FTP-&gt;new("<A=20
    =
href=3D'ftp://ftp.asksathia.com",Debug'>ftp.asksathia.com",Debug</A> =
=3D&gt; 0);=20
    <BR>$ftp-&gt;login("asksathia","allowme"); =
<BR>$ftp-&gt;cwd("/htdocs");=20
    <BR>$ftp-&gt;get("des.zip"); <BR>my $stat =3D $ftp-&gt;status; =
<BR>my=20
    $full_stat =3D $ftp-&gt;code; <BR># $stat contains the first digit; =
usually=20
    all <BR># that you need to do is test if it is equal <BR># to 2. =
$full_stat=20
    contains the full 3-digit <BR># value but is seldom needed=20
    <BR>printf("Status: %d Full Status: %d\n",$stat,$full_stat); <BR># =
Sample=20
    Test <BR>if ($stat =3D=3D 2) <BR>{ <BR>&nbsp;&nbsp;&nbsp; print =
"Get was OK\n";=20
    <BR>} <BR>else <BR>{ <BR>&nbsp;&nbsp;&nbsp; print "Get was BAD\n"; =
<BR>}=20
    <BR>$ftp-&gt;quit;</FONT></DIV></BLOCKQUOTE>
  <DIV dir=3Dltr><FONT face=3DArial size=3D2>Thanks </FONT></DIV>
  <DIV dir=3Dltr><FONT face=3DArial=20
size=3D2>Imthiaz</FONT></DIV></BLOCKQUOTE></BODY></HTML>

<P><FONT SIZE=3D2 =
FACE=3D"Arial">*********************************************************=
***************** </FONT></P>

<P><FONT SIZE=3D2 FACE=3D"Arial">This email (including any attachments) =
is intended for the sole use of the intended recipient/s and may =
contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. =
Any review or reliance by others or copying or distribution or =
forwarding of any or all of the contents in this message is STRICTLY =
PROHIBITED. If you are not the intended recipient, please contact the =
sender by email and delete all copies; your cooperation in this regard =
is appreciated.</FONT></P>

<P><FONT SIZE=3D2 =
FACE=3D"Arial">*********************************************************=
*****************</FONT></P>

------_=_NextPart_001_01C24028.70AB9E00--

--------------InterScan_NT_MIME_Boundary--

Other related posts: