Can't get attributes of file error during FTP download

Advertisement

Guest

Can't get attributes of file error during FTP download

I have a powershell script that I am useing and I cannot download a file. I recieve the error "Can't get attributes of file..." and inside my log file it says:

      <message>Can't get attributes of file '/ /download/100_MBytes.txt'.</message>
      <message>Could not retrieve file information</message>
      <message>SIZE: Not owner</message

But I am able to download the file using the GUI. What could cause this? I am using the path "/download/<filename>" but when I go into the GUI the root folder is just "/", could this be the cause of it? My other servers have the path "/home/...". I have attached my powershell script and my log file. Note: I have removed all of the login information due to it being confidential.

# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"
 
# Session.FileTransferProgress event handler
 
function FileTransferProgress
{
    param($e)
 
    # New line for every new file
    if (($script:lastFileName -ne $Null) -and
        ($script:lastFileName -ne $e.FileName))
    {
        Write-Host
    }
 
    # Print transfer progress
    Write-Host -NoNewline ("`r{0} ({1:P0})" -f $e.FileName, $e.FileProgress)
 
    # Remember a name of the last file reported
    $script:lastFileName = $e.FileName
}
 
# Main script
 
$script:lastFileName = $Null
 
try
{
   Write-Host "Please wait while startup procedures run"
    $sessionOptions = New-Object WinSCP.SessionOptions
    $sessionOptions.Protocol = [WinSCP.Protocol]::ftp
   $sessionOptions.HostName = "xxx"
    $sessionOptions.UserName = "xxxx"
    $sessionOptions.Password = "xxxx"
   $sessionOptions.FtpMode = [WinSCP.FtpMode]::passive
   $sessionOptions.AddRawSettings("SendBuf","4096");   
   #$sessionOptions.AddRawSettings("Compression","1");
   #$sessionOptions.AddRawSettings("Cipher","blowfish,aes,3des,WARN,arcfour,des");
   #$sessionOptions.AddRawSettings("Cipher","blowfish");
   #$sessionOptions.AddRawSettings("Compression","1");

    #$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
 
    $session = New-Object WinSCP.Session
    try
    {
      
        # Will continuously report progress of transfer
        $session.add_FileTransferProgress( { FileTransferProgress($_) } )
 
        # Connect
        $session.Open($sessionOptions)
      $session.DebugLogPath = "WinSCP.log"
      $remotePath = "/download/100_MBytes.txt"
        $localPath = "C:\download\100_MBytes.txt"
      
      # Force binary transfer        
        $transferOptions = New-Object WinSCP.TransferOptions
        $transferOptions.TransferMode = [WinSCP.TransferMode]::Ascii
      
      Write-Host "Starting download"
        $start = Get-Date  # Get start time
      
      #$directory = $session.ListDirectory("/download")
 
        #foreach ($fileInfo in $directory.Files)
        #{
        #    Write-Host ("{0} with size {1}, permissions {2} and last modification at {3}" -f
         #       $fileInfo.Name, $fileInfo.Length, $fileInfo.FilePermissions, $fileInfo.LastWriteTime)
        #}
      
        # Download the file and throw on any error
      $session.GetFiles($remotePath, $localPath).Check()
      
      # Get end time and calculate throughput
      $duration = (Get-Date) - $start
        $size = (Get-Item $localPath).Length
      $sizeInKb = (Get-Item $localPath).Length / 1024
        $speed = $sizeInKb / $duration.TotalSeconds
      
      Write-Host 
      Write-Host ("Downloaded file {0} to {1}" -f $remotePath, $localPath)
        Write-Host ("Size {0:N0} B | Time {1:hh\:mm\:ss}" -f $size, $duration)
        Write-Host ("Speed {0:N0} KB/s" -f $speed)
    }
    finally
    {
        # Terminate line after the last file (if any)
        if ($script:lastFileName -ne $Null)
        {
            Write-Host
        }
 
        # Disconnect, clean up
        $session.Dispose()
    }
 
    exit 0
}
catch [Exception]
{
    Write-Host $_.Exception.Message
    exit 1
}

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Can't get attributes of file error during FTP download

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

mrsmalltalk
Joined:
Posts:
10

hi,

i'm having a similar problem. i'm downloading 2 files from ES File Explorer running on Android 5.0.2 to winscp 5.7.6 (5874) on win7. i'm downloading 2 files from the same directory. i'm using with bat files. one consistently works and the other fails. i have attached the 2 .bat files and the 2 winscp logs. the files both exist on the android and i don't think i have any typos. if necessary i can send the actual files. they are small.

john
Description: i put all logs and batch files here

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

mrsmalltalk wrote:

i'm having a similar problem. i'm downloading 2 files from ES File Explorer running on Android 5.0.2 to winscp 5.7.6 (5874) on win7. i'm downloading 2 files from the same directory. i'm using with bat files. one consistently works and the other fails. i have attached the 2 .bat files and the 2 winscp logs. the files both exist on the android and i don't think i have any typos. if necessary i can send the actual files. they are small.

There's no 20160120DataFromAndroid.txt in the /66DATA99/Input/BocceLog/ directory.

-rw-r--r-- 1 nobody nobody 1172 Jan 20 10:22 DataToAndroid.txt
-rw-r--r-- 1 nobody nobody 31 Jan 20 15:08 CurrentFilename.txt
-rw-r--r-- 1 nobody nobody 960 Jan 11 15:55 20160111DataToSmalltalk.txt
-rw-r--r-- 1 nobody nobody 472 Jan 14 12:24 20160113DataToSmalltalk.txt
-rw-r--r-- 1 nobody nobody 412 Jan 08 15:42 20160108DataToSmalltalk.txt
-rw-r--r-- 1 nobody nobody 903 Jan 18 15:18 20160118DataToSmalltalk.txt
-rw-r--r-- 1 nobody nobody 875 Jan 20 15:08 20160120DataToSmalltalk.txt

.

Reply with quote

Advertisement

mrsmalltalk
Joined:
Posts:
10

my mistake.

i'm generating batch files on the fly. to test i cut and pasted from another batch file which obviously had the wrong file name but correct date, so the asterisk worked based on a date hit.

again, my apologies.

john

Reply with quote

Advertisement

You can post new topics in this forum