in reply to Re^3: FTPSSL Bad file number
in thread FTPSSL Bad file number

hi, this is from debug file
>>> PASV <<< 227 Entering Passive Mode (217,151,192,136,195,210) --- Host (217.151.192.136) Port (50130) >>> RETR -rwxr-xr-x 1 260 410 1571 Mar 5 08:32 + B0000198800028226.xml.enc <<< 553 Prohibited file name: -rwxr-xr-x 1 260 410 + 1571 Mar 5 08:32 B000 0198800028226.xml.enc >>> ABOR <<< 226 Since you see this ABOR must've succeeded >>> QUIT <<< 221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
This from the prompt
553 Prohibited file name: -rwxr-xr-x 1 260 410 +1571 Mar 5 08:32 B0000198800028226.xml.enc at /usr/local/bin/debitech line 156
And here are the lines in my script
151 # GET ALL FILES (*.enc) TO LOCAL DIRECTORY, DE +LETE THEM ON SERVER 152 foreach $file (@files) { 153 if ( !$error_flag && $file =~ m/\.enc$ +/ ) { 154 $report = $report . " Retriev +ing file $file\n"; 155 if ( !$debug ) { 156 $ftp->get($file) or $e +rror_flag = 1; 157 $ftp->quit() if $error +_flag; 158 $ftp->delete($file) or + $error_flag = 1; 159 $ftp->quit() if $error +_flag; 160 }

Replies are listed 'Best First'.
Re^5: FTPSSL Bad file number
by hippo (Archbishop) on Mar 05, 2015 at 09:33 UTC

    This is good info - it clearly shows that the elements of @files are not filenames such as B0000198800028226.xml.enc (which they should be) but rather long listings such as:

    -rwxr-xr-x    1 260        410              1571 Mar  5 08:32 B0000198800028226.xml.enc

    If you populate @files correctly in the first place then the error messages will disappear.

      Thanks!! Now it works. I use nlst() instead. As I wrote in my first post, I'm not a programmer so I'm glad for all help i get.
Re^5: FTPSSL Bad file number
by afoken (Chancellor) on Mar 05, 2015 at 09:37 UTC
    156 $ftp->get($file) or $e +rror_flag = 1; 157 $ftp->quit() if $error +_flag; 158 $ftp->delete($file) or + $error_flag = 1; 159 $ftp->quit() if $error +_flag;

    What happens when $ftp->get($file) in line 156 fails?

    1. $error_flag is set in the same line
    2. $ftp->quit() is called, in line 157. Tthis will close the FTP connection.
    3. $ftp->delete() is called, in line 158. This will fail, because the FTP connection in $ftp is closed.
    4. $error_flag is set again, in line 158.
    5. $ftp->quit() is called again, in line 159. This will fail again, because the FTP connectin in $ftp is still closed.

    I don't think this is what you really want. You want to abort when $ftp->get($file) fails. Why don't you use die and eval {...} instead of fiddling with error flags? Or at least break out of the foreach loop using last?

    Anonymous Monk explained this problem in the first reply, but it seems you ignored it or did not understand it.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)