Jump to content

Ftp FILE Put Issue


Recommended Posts

I am trying to upload file on my personal IIS FTP server remotly using other client which successufully upload files

but its failing to upload via this 

 

#include <FTPEx.au3>

$server = 'xx.47.4.xxx'
$username = 'Admin'
$pass = 'xxxx'
$FTPFile = "/_FTP_FilePut.au3"
$ULFile = @ScriptDir & "\_FTP_FilePut.au3"



$Open = _FTP_Open('MyFTP')
$bOpen = @error
If Not $bOpen Then
    $Conn = _FTP_Connect($Open, $server, $username, $pass, 1 ,50100)
    $bCon = @error
    If Not $bCon Then
        If _FTP_FilePut($Conn, $ULFile,  $FTPFile) Then
            MsgBox(0, "Upload", "erfolgreich")
            $Ftpc = _FTP_Close($Open)
        Else
            MsgBox(0, "Upload", "fehlgeschlagen")
            ConsoleWrite("Upload: " & $bCon & " " & @extended & @CRLF)
        EndIf
    Else
        MsgBox(0, "Connect", "fehlgeschalagen")
        ConsoleWrite("Connect: " & $bCon & " " & @extended & @CRLF)
    EndIf
Else
    MsgBox(0, "OPen", "fehlgeschalagen")
    ConsoleWrite("Open " & $bOpen & " " & @extended & @CRLF)
EndIf

iis ftp log

2015-04-27 19:38:26 xxx.255.211.68 - 192.168.1.2 50100 ControlChannelOpened - 0 -
2015-04-27 19:38:27 xxx.255.211.68 - 192.168.1.2 50100 USER 331 0 -
2015-04-27 19:38:28 xxx.255.211.68 Admin-PC\Admin 192.168.1.2 50100 PASS 230 0 /
2015-04-27 19:38:28 xxx.255.211.68 Admin-PC\Admin 192.168.1.2 50100 TYPE 200 0 -
2015-04-27 19:38:29 xxx.255.211.68 Admin-PC\Admin 192.168.1.2 50100 PASV 227 0 -
2015-04-27 19:38:29 192.168.1.5 Admin-PC\Admin 192.168.1.2 49974 DataChannelOpened - 0 -
2015-04-27 19:38:29 192.168.1.5 Admin-PC\Admin 192.168.1.2 49974 DataChannelClosed - 1236 -
2015-04-27 19:38:30 xxx.255.211.68 Admin-PC\Admin 192.168.1.2 50100 STOR 425 1236 /_FTP_FilePut.au3
2015-04-27 19:38:35 xxx.255.211.68 Admin-PC\Admin 192.168.1.2 50100 ControlChannelClosed - 0 -

 ftp log for other client which successfully uploaded file

2015-04-27 19:19:24 xxx.255.211.69 - 192.168.1.2 50100 ControlChannelOpened - 0 -
2015-04-27 19:19:24 xxx.255.211.69 - 192.168.1.2 50100 USER 331 0 -
2015-04-27 19:19:25 xxx.255.211.69 Admin-PC\Admin 192.168.1.2 50100 PASS 230 0 /
2015-04-27 19:19:26 xxx.255.211.69 Admin-PC\Admin 192.168.1.2 50100 SYST 215 0 -
2015-04-27 19:19:27 xxx.255.211.69 Admin-PC\Admin 192.168.1.2 50100 PWD 257 0 -
2015-04-27 19:19:27 xxx.255.211.69 Admin-PC\Admin 192.168.1.2 50100 PASV 227 0 -
2015-04-27 19:19:29 xxx.255.211.69 Admin-PC\Admin 192.168.1.2 49970 DataChannelOpened - 0 -
2015-04-27 19:19:29 xxx.255.211.69 Admin-PC\Admin 192.168.1.2 49970 DataChannelClosed - 0 -
2015-04-27 19:20:07 xxx.255.211.69 Admin-PC\Admin 192.168.1.2 50100 STOR 226 0 /_FTP_FilePut.au3
2015-04-27 19:20:08 xxx.255.211.69 Admin-PC\Admin 192.168.1.2 50100 MDTM 213 0 /_FTP_FilePut.au3
2015-04-27 19:22:07 xxx.255.211.69 Admin-PC\Admin 192.168.1.2 50100 ControlChannelClosed - 1236 -

 

Edited by autoitxp
Link to comment
Share on other sites

I know very little about IIS, but the first thing I would try changing is

$FTPFile = "/_FTP_FilePut.au3" Try backslash, try no slash, etc.

The next thing is there are quite a few flags for _FTP_FilePut.  You may need to research what settings IIS uses.  I think this uses the DLL in windows, and would have the same issues as the built command line prompt ftp client.

 

Somewhere there is a setting to increase the verbosity of the IIS log.  If it is a busy server, watch out.

 

Please note: This does not encrypt or secure the password or channel at all.

Link to comment
Share on other sites

Are you getting any error messages from your script?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

ok Are you getting any error messages from your script?

​i am not getting any script errors  i think i found out problem but donno how to deal   

DataChannelOpened  with local ip not remote ip look carefully

 i think _FTP_FilePut opening session with local ip not remote ip. i think its autoit bug 

2015-04-27 19:38:29 192.168.1.5 Admin-PC\Admin 192.168.1.2 49974 DataChannelOpened - 0 -
2015-04-27 19:38:29 192.168.1.5 Admin-PC\Admin 192.168.1.2 49974 DataChannelClosed - 1236 -

and other ftp client which i'm using successfully upload to remote ip DataChannelOpened opened with remotely 

 2015-04-27 19:19:29 xxx.255.211.69 Admin-PC\Admin 192.168.1.2 49970 DataChannelOpened - 0 -
2015-04-27 19:19:29 xxx.255.211.69 Admin-PC\Admin 192.168.1.2 49970 DataChannelClosed - 0 -

Edited by autoitxp
Link to comment
Share on other sites

https://support.microsoft.com/en-us/kb/2505047

FTP 7.5 resets the data connection if an FTP client tries to use a port lower than 1024 for the data connection
In earlier versions of IIS, an FTP client could choose to use a port lower than 1024 for the data connection, in both passive mode and active mode FTP communications. Beginning in FTP 7.5, when an FTP client tries to use a port lower than 1024 for the data connection, FTP 7.5 will reset the underlying TCP connection. For example, if an FTP client tries to do a passive-mode upload of a file using the STOR command, and tries to use a port lower than 1024 for the data connection, the upload will fail and entries similar to the following will be written to the FTP log:
 

2012-01-15 02:08:16 123.456.789.0 user01 123.1.1.1 40063 DataChannelOpened - - 0 0
2012-01-15 02:08:16 123.456.789.0 user01 123.1.1.1 40063 DataChannelClosed - - 1236 38
2012-01-15 02:08:16 123.456.789.0 user01 123.1.1.1 21 STOR file.txt 425 1236 0

NOTE: For an active-mode FTP upload using a data port less than 1024, the Win32 status will be 87 instead of 1236.

This behavior occurs because in FTP 7.5 ports in the range of 0-1023 are now reserved for system processes or for programs 

That piece of log looks exactly like yours. You tell it to use 50100 as a port, and the FTPEx.au3 doesn't seem to do anything strange with that number, but _ftp_fileput shoud set the @error and more importantly the @extended. Try to get those for the fileput operation, because apparently your connect works.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

We're going to need more of your script than this to try and help. What is in $x for example, have you used _FTP_Connect prior to this, things like this. Is the server using SFTP or just standard FTP?

​Using simple ftp server IIS 7.5 on windows 7 sp1 ultimate USING port range 49900-50000 NAT forwarded, allowed in firewall and ftp port which is 50100 i am not using port range below 1024 

and using above simple script to test if it upload my file or not

#include <FTPEx.au3>


Local $sServer = 'xx.47.250.xxx'
Local $sUsername = 'Admin'
Local $sPass = '1234'
Local $sport = 50100


Local $hOpen = _FTP_Open('MyFTP')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass, 1 ,$sport)
local $put = _FTP_FilePut ( $hConn, @ScriptDir & "\" &@ScriptName, "/Remote.au3" )

if $put = 0 then
MsgBox(0 , '', @error)
Else
MsgBox(0 ,'' , 'uploaded sucsses... deleteing now!')
_FTP_FileDelete ( $hConn, "/Remote.au3"  )
endif


sleep(1000)
Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)

nothing uploaded and shows same IIS error log above mentioned 

Edited by autoitxp
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...