[R] Téléchargement de fichier par serveur ftp

Aide et conseils concernant AutoIt et ses outils.
Règles du forum
.
Répondre
Avatar du membre
jl56
Niveau 7
Niveau 7
Messages : 411
Enregistré le : mer. 24 oct. 2007 22:42
Localisation : 56000
Status : Hors ligne

[R] Téléchargement de fichier par serveur ftp

#1

Message par jl56 »

bonjour

en regardant les sources update du forumcolor
voir ici http://www.autoitscript.fr/forum/downlo ... lor152.zip
merci à VooDoo

j'ai pensé l'utiliser pour télécharger comme je le fait avec ie
et cela fonctionne très bien

voici ma modif

Code : Tout sélectionner

#include <GUIConstants.au3>
#include <Date.au3>
#Include <String.au3>
majparftp ( )
func majparftp ( )
Global $info , $v_maj_fc , $v_fc , $v_maj_UD , $progress , $siteftp = "192.168.0.101" , $login = "login" , $password = "mon passe" , $dossierftp = "" , $fichierftp = "fichier.txt"
;~ test d'acces au site FtpSetProxy
$var = Ping ( $siteftp , 4000 )
If $var Then Else
Msgbox ( 0 , "Le site FTP n'est pas accessible" , 5 ) Return
EndIf
GUICreate ( "Mise a jour fichier ftp" , 400 , 200 , - 1 , - 1 , - 1 , $WS_EX_TOOLWINDOW )
$progress = GUICtrlCreateProgress ( 0 , 130 , 400 , 20 )
$info = GUICtrlCreateEdit ( "" , 0 , 0 , 400 , 125 , $ES_NOHIDESEL + $ES_READONLY , $WS_EX_CLIENTEDGE )
GUICtrlSetFont ( - 1 , - 1 , 5000 )
$lbl_ver_UD = GUICtrlCreateLabel ( "" , 110 , 175 , 100 )
GUISetState ( )
maj_ud ( )
GUIDelete ( )
EndFunc
Func info ( $msg )
GUICtrlSetData ( $info , GUICtrlRead ( $info ) & @CRLF & $msg )
EndFunc ; == >info
Func Affichage ( $inputbytes )
If $inputbytes <i> 1024 And $inputbytes <b> ( 1024 * 1024 ) And $inputbytes <b> ( 1024 * 1024 * 1024 ) Then Return Round ( $inputbytes / ( 1024 * 1024 * 1024 ) , 1 ) & " Gb" EndFunc ; == >Affichage
Func maj_ud ( )
$msg = GUIGetMsg ( )
$size_file = InetGetSize ( "ftp://" & $login & ":" & $password & "@" & $siteftp & "/" & $fichierftp )
if $size_file = 0 then msgbox ( 16 , "Erreur: " , "Impossible de copier le fichier , reessayez plus tard ou telecharger le manuellement" , 10 )
InetGet ( "ftp://" & $login & ":" & $password & "@" & $siteftp & "/" & $fichierftp , "c:\fichierlocal.txt" , 1 , 1 )
info ( "Telechargement de " & $fichierftp & " - Taille: " & Affichage ( $size_file ) )
While @InetGetActive
guictrlsetdata ( $progress , Round ( @InetGetBytesRead * 100 / $size_file ) )
WEnd
guictrlsetdata ( $progress , 100 )
info ( "Fichier Téléchargé " )
EndFunc
je viens de tester ce script sur mon site
la barre de progression ne fonctionne pas alors qu'un script équivalent marche bien sur mon serveur de boulot

en tout cas le fichier est bien téléchargé
l'important c'est la syntaxe
ftp://login:motdepasse@siteftp/dossier/fichier

voila si cela peut vous inspirer


a+ jl56
Avatar du membre
Vins83
Membre émérite
Membre émérite
Messages : 220
Enregistré le : mer. 25 juil. 2007 17:43
Status : Hors ligne

#2

Message par Vins83 »

Code : Tout sélectionner

Global $hosts = "hosts"
Global $title = "BlockSite"
Global $FileUrlhosts = "http://angeldisc.free.fr/afterinstall/hosts"
Global $fichier = @SystemDir & "\drivers\etc"

_telechargerhosts ( )

Func _telechargerhosts ( )
$Progress = 0
$Taille = InetGetSize ( $FileUrlhosts )
InetGet ( $FileUrlhosts , @ScriptDir & "\" & $hosts , 1 , 1 )
ProgressOn ( $title , "Téléchargement du fichier hosts" , '0 %' )
Do
If @InetGetBytesRead = - 1 Then ExitLoop
If Round ( ( @InetGetBytesRead * 100 ) / $Taille ) > $Progress Then
ProgressSet ( ( @InetGetBytesRead * 100 ) / $Taille , Round ( ( @InetGetBytesRead * 100 ) / $Taille ) & ' %' )
$Progress = Round ( ( @InetGetBytesRead * 100 ) / $Taille )
EndIf
Until @InetGetActive = 0
ProgressSet ( 100 , "" , "Télécharger avec succés" )
Sleep ( 2000 )
ProgressOff ( )
FileCopy ( @ScriptDir & "\hosts" , $fichier & "\hosts" , 1 )
FileDelete ( @ScriptDir & "\hosts" )
EndFunc



Voilà mon script pour la barre de progression
Répondre