Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Net::FTP does not seem to work properly in Cygwin/Windows 7

Expand Messages
  • Tim Lewis
    I cannot answer the question as to why Cygwin is causing an issue. I use both Windows FTP and Filezilla. However, I do have code in my ftp scripts to check
    Message 1 of 7 , Nov 29, 2010
    • 0 Attachment
      I cannot answer the question as to why Cygwin is causing an issue. I use both Windows FTP and Filezilla. However, I do have code in my ftp scripts to check the filesize, and then email me if it does not match. I have included an example below based on your original code.
      Tim

      #!/usr/local/bin/perl

      #! /usr/bin/perl -w
      #
      # script to FTP images to vex.net and move such files to the "uploaded"
      # directory.

      use Net::FTP;
      use File::Copy;


      my $filename = $ARGV[0];
      my $wd = "public_html/000HTML_sj/wp-content/uploads/";
      my $ftpSite='ftp.vex.net';
      my $ftpUser='username';
      my $ftpPassword='password';

      $ftp = Net::FTP->new($ftpSite, Debug => 0)
      or die "Cannot connect to $ftpSite: $@";

      print "Logging in ...\n";
      $ftp->login($ftpUser,$ftpPassword) or die "Cannot login ", $ftp->message;

      $ftp->cwd($wd) or die "Cannot change working directory ", $ftp->message;

      print "Uploading $filename to $wd ...\n";
      $ftp->put($filename) or die "put failed ", $ftp->message;

      my @ftpList=$ftp->ls;
      print "Checking the existence of the file after the FTP process.\n";
      my $ftpFileCount = @ftpList;
      my $fileSize = -s $completeFile;
      my $ftpFileFound="false";
      my $ftpFileSizeMatch="false";
      my $lastSlash = (rindex($completeFile,"\\") + 1);
      my $fileName = substr($completeFile,$lastSlash);
      print "Checking file $fileName\n";
      for (my $count=0;$count<$ftpFileCount;$count++) {
      my $ftpFile = @ftpList[$count];
      if (uc($filename) eq uc($ftpFile)) {
      $ftpFileFound = "true";
      my $dosFileSize = -s $filename;
      my $ftpFileSize = $ftp->size($ftpFile);
      print "Byte size on local: $dosFileSize Byte size on remote: $ftpFileSize\n";
      if ($ftpFileSize eq $dosFileSize) {
      $ftpFileSizeMatch="true";
      } # end of if
      } # end of if
      } # end of for
      if ($ftpFileFound eq "true") {
      print "File was found on remote.\n";
      if ($ftpFileSizeMatch eq "true") {
      print "File size on remote matches file size on local.\n";
      } # end of if
      else {
      print "FILE SIZE DOES NOT MATCH!!\n";
      } # end of else
      } # end of if
      else {
      print "FILE IS MISSING!!\n";
      } # end of else

      #system ("mv", $filename, "uploaded");

      $ftp->quit;




      ---- phrankpsinatra <phrankpsinatra@...> wrote:
      > I am new to the group, and I have a problem in getting Perl's Net::FTP module to work properly under a copy of Cygwin I have installed in Windows 7 (64-bit).
      >
      > I am using Net::FTP as a speedy way of uploading jpegs and other binaries from my desktop to my website. Some jpegs go through OK, but there are several files which are deformed in some way. Audio and video files often fail if played after being uploaded with this script.
      >
      > Below is my script. It's quite simple:
      >
      > #! /usr/bin/perl -w
      > #
      > # script to FTP images to vex.net and move such files to the "uploaded"
      > # directory.
      >
      > use Net::FTP;
      > use File::Copy;
      >
      > my $filename = $ARGV[0];
      > my $wd = "public_html/000HTML_sj/wp-content/uploads/";
      >
      > $ftp = Net::FTP->new("ftp.vex.net", Debug => 0)
      > or die "Cannot connect to ftp.vex.net: $@";
      >
      > print "Logging in ...\n";
      > $ftp->login("USER",'PASS') or die "Cannot login ", $ftp->message;
      >
      > $ftp->cwd($wd) or die "Cannot change working directory ", $ftp->message;
      >
      > print "Uploading $filename to $wd ...\n";
      > $ftp->put($filename) or die "put failed ", $ftp->message;
      > system ("mv", $filename, "uploaded");
      >
      > $ftp->quit;
      >
      >
    • Phrank Psinatra
      I can t remember who pointed it out to me, but the bug in this program was a simple one, where all I needed to do was to add ftp- binary; before downloading.
      Message 2 of 7 , Dec 7, 2010
      • 0 Attachment
        I can't remember who pointed it out to me, but the bug in this program was a
        simple one, where all I needed to do was to add

        ftp->binary;

        before downloading. Looks like Cygwin's Net::FTP assumes ASCII by default.


        Paul



        ________________________________
        From: Tim Lewis <twlewis@...>
        To: perl-beginner@yahoogroups.com
        Cc: phrankpsinatra <phrankpsinatra@...>
        Sent: Mon, November 29, 2010 12:54:04 PM
        Subject: Re: [PBML] Net::FTP does not seem to work properly in Cygwin/Windows 7

        I cannot answer the question as to why Cygwin is causing an issue. I use both
        Windows FTP and Filezilla. However, I do have code in my ftp scripts to check
        the filesize, and then email me if it does not match. I have included an
        example below based on your original code.
        Tim

        #!/usr/local/bin/perl

        #! /usr/bin/perl -w
        #
        # script to FTP images to vex.net and move such files to the "uploaded"
        # directory.

        use Net::FTP;
        use File::Copy;


        my $filename = $ARGV[0];
        my $wd = "public_html/000HTML_sj/wp-content/uploads/";
        my $ftpSite='ftp.vex.net';
        my $ftpUser='username';
        my $ftpPassword='password';

        $ftp = Net::FTP->new($ftpSite, Debug => 0)
        or die "Cannot connect to $ftpSite: $@";

        print "Logging in ...\n";
        $ftp->login($ftpUser,$ftpPassword) or die "Cannot login ", $ftp->message;

        $ftp->cwd($wd) or die "Cannot change working directory ", $ftp->message;

        print "Uploading $filename to $wd ...\n";
        $ftp->put($filename) or die "put failed ", $ftp->message;

        my @ftpList=$ftp->ls;
        print "Checking the existence of the file after the FTP process.\n";
        my $ftpFileCount = @ftpList;
        my $fileSize = -s $completeFile;
        my $ftpFileFound="false";
        my $ftpFileSizeMatch="false";
        my $lastSlash = (rindex($completeFile,"\\") + 1);
        my $fileName = substr($completeFile,$lastSlash);
        print "Checking file $fileName\n";
        for (my $count=0;$count<$ftpFileCount;$count++) {
        my $ftpFile = @ftpList[$count];
        if (uc($filename) eq uc($ftpFile)) {
        $ftpFileFound = "true";
        my $dosFileSize = -s $filename;
        my $ftpFileSize = $ftp->size($ftpFile);
        print "Byte size on local: $dosFileSize Byte size on remote:
        $ftpFileSize\n";
        if ($ftpFileSize eq $dosFileSize) {
        $ftpFileSizeMatch="true";
        } # end of if
        } # end of if
        } # end of for
        if ($ftpFileFound eq "true") {
        print "File was found on remote.\n";
        if ($ftpFileSizeMatch eq "true") {
        print "File size on remote matches file size on local.\n";
        } # end of if
        else {
        print "FILE SIZE DOES NOT MATCH!!\n";
        } # end of else
        } # end of if
        else {
        print "FILE IS MISSING!!\n";
        } # end of else

        #system ("mv", $filename, "uploaded");

        $ftp->quit;




        ---- phrankpsinatra <phrankpsinatra@...> wrote:
        > I am new to the group, and I have a problem in getting Perl's Net::FTP module
        >to work properly under a copy of Cygwin I have installed in Windows 7 (64-bit).
        >
        > I am using Net::FTP as a speedy way of uploading jpegs and other binaries from
        >my desktop to my website. Some jpegs go through OK, but there are several files
        >which are deformed in some way. Audio and video files often fail if played after
        >being uploaded with this script.
        >
        > Below is my script. It's quite simple:
        >
        > #! /usr/bin/perl -w
        > #
        > # script to FTP images to vex.net and move such files to the "uploaded"
        > # directory.
        >
        > use Net::FTP;
        > use File::Copy;
        >
        > my $filename = $ARGV[0];
        > my $wd = "public_html/000HTML_sj/wp-content/uploads/";
        >
        > $ftp = Net::FTP->new("ftp.vex.net", Debug => 0)
        > or die "Cannot connect to ftp.vex.net: $@";
        >
        > print "Logging in ...\n";
        > $ftp->login("USER",'PASS') or die "Cannot login ", $ftp->message;
        >
        > $ftp->cwd($wd) or die "Cannot change working directory ", $ftp->message;
        >
        > print "Uploading $filename to $wd ...\n";
        > $ftp->put($filename) or die "put failed ", $ftp->message;
        > system ("mv", $filename, "uploaded");
        >
        > $ftp->quit;
        >
        >



        ------------------------------------

        Unsubscribing info is here:
        http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links






        [Non-text portions of this message have been removed]
      • Phrank Psinatra
        I don t use move (from DOS), instead favouring Cygwin s mv, which I am more familiar with. I would need to look up the syntax to remind myself of rename() ,
        Message 3 of 7 , Dec 7, 2010
        • 0 Attachment
          I don't use "move" (from DOS), instead favouring Cygwin's mv, which I am more
          familiar with. I would need to look up the syntax to remind myself of
          "rename()", where I don't if I want to use "system()" or "mv". Truth be known,
          it was probably pasted that way from the web page I took it from (don't know
          where from, now).

          Paul




          ________________________________
          From: "merlyn@..." <merlyn@...>
          To: phrankpsinatra <phrankpsinatra@...>
          Cc: perl-beginner@yahoogroups.com
          Sent: Sun, November 28, 2010 11:46:36 PM
          Subject: Re: [PBML] Net::FTP does not seem to work properly in Cygwin/Windows 7

          >>>>> "phrankpsinatra" == phrankpsinatra <phrankpsinatra@...> writes:

          phrankpsinatra> system ("mv", $filename, "uploaded");

          Why are you doing this *on windows*, when you have rename() available?

          --
          Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
          <merlyn@...> http://www.stonehenge.com/merlyn/>
          Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
          See http://methodsandmessages.posterous.com/ for Smalltalk discussion


          ------------------------------------

          Unsubscribing info is here:
          http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links






          [Non-text portions of this message have been removed]
        • Tim Lewis
          I have a script that uses MIME:Lite and Net:SMTP to send out emails from a server. This script has worked for months with no problem. It will no longer send
          Message 4 of 7 , Dec 9, 2010
          • 0 Attachment
            I have a script that uses MIME:Lite and Net:SMTP to send out emails from a
            server. This script has worked for months with no problem. It will no
            longer send emails. I can send emails directly with Net:SMTP, and I can
            also send emails through VB using CDO.Message. There is something about the
            server that has changed in which it no longer likes the MIME version. I
            have checked the event logs, but cannot find any issue there. I would be
            extremely appreciative if someone has an idea of what can be wrong with
            this.



            Tim





            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.