Jump to content

request via proxy


Recommended Posts

Hello 
 
 
I have to get some files with ftp,   in a PC with a proxy connection. 
When I run the code that I write bellow, the request is directly to the ftp'server.
I need that the request (to the ftp server) will be via proxy.
 
 
 Local $sServer = 'xxxxxxxxxxxxx'
    Local $sUsername = 'xxx'
    Local $sPass = 'xxxxxxxxxxx'
 
    Local $hOpen = _FTP_Open('MiFTP Control', $INTERNET_OPEN_TYPE_PRECONFIG )
  
   If @error Then
        MsgBox($MB_SYSTEMMODAL, '_FTP_open', 'ERROR=' & @error,2)
    endif
  
   Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
 
    If @error Then
        MsgBox($MB_SYSTEMMODAL, '_FTP_Connect', 'ERROR=' & @error,2)
    endif
 
 
     _FTP_FileGet ( $hConn,'/Boletines/wstodos.txt', @DesktopDir&'\sigmet-airmet\control\ACC\wstodos'&$rn&'.txt', False, 0, $INTERNET_FLAG_RELOAD  )
 
     If @error Then
          MsgBox($MB_SYSTEMMODAL, '_FTP_get', 'ERROR=' & @error)
    endif
 
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;,
 
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
        Local $iFtpc = _FTP_Close($hConn)
       Local $iFtpo = _FTP_Close($hOpen)
 
 
Thanks
Javier
Link to comment
Share on other sites

Did you try to use FtpSetProxy ? or the optional prameter of

_FTP_Open

Opens an FTP session

#include <FTPEx.au3>
_FTP_Open ( $sAgent [, $iAccessType = $INTERNET_OPEN_TYPE_DIRECT [, $sProxyName = '' [, $sProxyBypass = '' [, $iFlags = 0]]]] )

Parameters

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

If you do not want to play around with those settings, you could easily automate a wget command via Autoit.

In wget you can set your proxy settings aswell.

 

RunWait(@scriptDir & '\wget.exe --no-cache --proxy=on --proxy-user=' & $YOURSUER & ' --proxy-passwd=' & $YOURPASSWORD & _
            ' --output-document="' & $YOURFILENAME & " ' & $YOURURL, @ScriptDir, @SW_HIDE)

 

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

You don't have to "really" install it. Use FileInstall. E.g. FileInstall "extracts" the exe out of your Autoitscript.exe in temp-folder, then do your stuff and then delete the wget.exe again.

P.S.: I tested FTP behind a proxy with the Autoit commands. It works.

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

When you say ' it works', it's the code of FTP for autoit or with wget commands? 

I tested _FTP_Open ( $sAgent, $INTERNET_OPEN_TYPE_PRECONFIG) 

and 

_FTP_Open ( $sAgent, $INTERNET_OPEN_TYPE_PROXY, ProxyName) 

and I haven't success, the later connection is directly to the FTP server. 

The access via proxy server needs the user and pass. When I do the request to a browser like explorer, it open a window to insert the user and pass. 

 

P. S. : ProxyName is name:port

Link to comment
Share on other sites

Try to use FTP_Open without the optional parameter and try to set the proxy via FTPProxySet instead.

Something like this:

 

#include <FTPEx.au3>
#include <MsgBoxConstants.au3>

FtpSetProxy($PROXY_SPECIFIED, 'yourProxy:21', @UserName, 'password')
HttpSetProxy($PROXY_SPECIFIED, 'yourProxy:8080', @UserName, 'password')

_Example()

Func _Example()
    Local $sServer = 'ftp.csx.cam.ac.uk' ; UNIVERSITY OF CAMBRIDGE ANONYMOUS FTP SERVER
    Local $sUsername = 'anonymous' ; or ''
    Local $sPass = 'bla@gmx.net'; or ''
    Local $Err, $sFTP_Message

    Local $hOpen = _FTP_Open('MyFTP Control')
    Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass, 1, 21, $INTERNET_SERVICE_HTTP,  $INTERNET_FLAG_TRANSFER_ASCII  )
    If @error Then
        MsgBox($MB_SYSTEMMODAL, '_FTP_Connect', 'ERROR=' & @error)
    Else
        ConsoleWrite('Handle: ' & $hConn & @CRLF)
        Local $aFile = _FTP_ListToArray2D($hConn, 0)
        ConsoleWrite('$sFileName = ' & $aFile[0][0] & '  -> Error code: ' & @error & @CRLF)
        ConsoleWrite('$sFileName = ' & $aFile[1][0] & ' size = ' & $aFile[1][1] & @error & @CRLF)
        ConsoleWrite('$sFileName = ' & $aFile[2][0] & ' size = ' & $aFile[2][1] & @CRLF)
    EndIf
    Local $iFtpc = _FTP_Close($hConn)
    Local $iFtpo = _FTP_Close($hOpen)
EndFunc   ;==>_Example

The proxy I have to use at work only supports ftp over http.

By the way, yes - I use wget instead of autoit functions for that stuff at work.

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

The last autoit code did not work via proxy.

The request was directly to the FTP server. This is always the problem. 

Perhaps autoit code only works, except for Cern proxy. 

I found Wininet functions. What do you think? 

Link to comment
Share on other sites

First of all, I'm not a proxy expert, but the Autoit code should work.

I use it behind a HTTP proxy in my company. The only "problem" is, I would have to tunnel ftp over HTTP if the proxy doesn't support this by default.

What is it, that you are really trying to do?

Did you try to use Filezilla, WinSCP, TotalCommander or whatever tool with your proxy?

Did that work?

 

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

I've worked out an app of products visualization from my company. I have a ftp server where I put these products. From other companies access to the server by the app. This app access automatically every 2 minutes and by a gui  allows the visualization.

From my company all things are OK. But from other company I try out and the request must be via proxy. The problem is that all the code I have tried out make the request directly to the server, I don't get the request to the proxy and It is locked.

I have tried few codes because I need the company computer. 

 

 

Link to comment
Share on other sites

Maybe you should talk to the guys that are responsible for the proxy in that company. Perhaps, they could help you out.

This seems to be no Autoit related problem.

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • 4 weeks later...

Are you doing it the way I suggested with FileInstall and deleting afterwards?

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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...