AutoHotkey Community → AutoHotkey → Support

Ftp multiple files begginning with Dam
Star ted b y V al i nar , Jan 27 201 2 06:1 7 PM

V a lin a r

Posted 27 January 2012 - 06:17 PM

A lr ig h t so i h a v e a n ot h er qu est for t h e g u r u 's h er e, I'm t r y in g t o set u p a n a u t om a t ic FT P of files g en er a t ed by a ct ion s u p h ig h er in t h is scr ipt . W h a t I'v e g ot so fa r r et u r n s n o er r or s on com pilin g or r u n n in g bu t it doesn 't a ct u a lly do a n y t h in g . Icon for t h e scr ipt fla sh es in t h e bot t om of t h e scr een bu t n ot h in g is don e. Ca n som eon e ch eck t h is a n d t ell w h er e m y er r or s a r e? Ba sica lly W in dow s sch edu ler la u n ch es t h is code a t 4 a m .

/* http://msdn.microsoft.com/library/e n-us/winine t/winine t/ftp_se ssions.asp http://msdn.microsoft.com/library/e n-us/winine t/winine t/inte rne tope n.asp http://msdn.microsoft.com/library/e n-us/winine t/winine t/inte rne tconne ct.asp */ Ft pCrea t eDi rect ory (Di rNa me ) { gl oba l i c_h In tern et r := Dl l Ca l l ("wi n i n et\FtpCreateDi rectory A ", "u i n t", i c_h In tern et, "str", Di rNa me ) If (ErrorLev el != 0 or r = 0) ret u rn 0 el se ret u rn 1 } Ft pRemov eDi rect ory (Di rNa me ) { gl oba l i c_h In tern et r := Dl l Ca l l ("wi n i n et\FtpRem ov eDi rectory A ", "u i n t", i c_h In tern et, "str", Di rNa me ) If (ErrorLev el != 0 or r = 0) ret u rn 0 el se ret u rn 1 } Ft pSet Cu rren t Di rect ory (Di rNa me ) { gl oba l i c_h In tern et r := Dl l Ca l l ("wi n i n et\FtpSetCu rren tDi rectory A ", "u i n t", i c_h In tern et, "str", Di rNa me ) If (ErrorLev el != 0 or r = 0) ret u rn 0 el se ret u rn 1 } Ft pPu t Fi l e (Loca l Fi l e , NewRemot eFi l e ="", Fl a gs=0) { ;Fl a gs: ;FTP_TRA N SFER_TY PE_UN KN OWN = 0 (Def a u l t s to FTP_TRA N SFER_TY PE_BIN A RY ) ;FTP_TRA N SFER_TY PE_A SCII = 1 ;FTP_TRA N SFER_TY PE_BIN A RY = 2 If NewRemot eFi l e = NewRemot eFi l e := Loca l Fi l e gl oba l i c_h In tern et r := Dl l Ca l l ("wi n i n et\FtpPu tFi l eA " , "u i n t", i c_h In tern et

"u i n t". "u i n t".dwA ccess: GEN ERIC_REA D . i c_h In tern et. "u i n t". "u i n t". i c_h In tern et . Fl a gs . i c_h In tern et . fof_h In tern et) ret u rn . 1 . "str". "str". i c_h In tern et. 0) .do n ot ov erwri te exi sti n g fi l es . Fl a gs=0) { . "u i n t". 0) . "u i n t".dwFl agsA n dA ttri bu tes . NewFi l e .FTP_TRA N SFER_TY PE_BIN A RY = 2 gl oba l i c_h In tern et fof_h In tern et := Dl l Ca l l ("wi n i n et\FtpOpen Fi l eA " . "u i n t".FTP_TRA N SFER_TY PE_A SCII = 1 . Fi l eNa me . "UIn t". "str".dwCon text If (ErrorLev el != 0 or fof_h In tern et = 0) ret u rn -1 Fi l eSi ze := Dl l Ca l l ("wi n i n et\FtpGetFi l eSi ze".FTP_TRA N SFER_TY PE_BIN A RY = 2 If NewFi l e = NewFi l e := Remot eFi l e gl oba l i c_h In tern et r := Dl l Ca l l ("wi n i n et\FtpGetFi l eA " .dwCon text If (ErrorLev el != 0 or r = 0) ret u rn 0 el se ret u rn 1 } Ft pGet Fi l e (Remot eFi l e .. Ex i st i n g. New) If (ErrorLev el != 0 or r = 0) ret u rn 0 el se . "str". Loca l Fi l e . Fl a gs . Fl a gs . "u i n t". "u i n t". "str". "u i n t". "str". 0 .FTP_TRA N SFER_TY PE_UN KN OWN = 0 (Def a u l t s to FTP_TRA N SFER_TY PE_BIN A RY ) . 0) Dl l Ca l l ("wi n i n et\In tern etCl oseHan dl e". "i n t". Fi l eNa me ) If (ErrorLev el != 0 or r = 0) ret u rn 0 el se ret u rn 1 } Ft pRen a meFi l e (Ex i st i n g.Fl a gs: . "str". New) { gl oba l i c_h In tern et r := Dl l Ca l l ("wi n i n et\FtpRen am eFi l eA ". "u i n t". NewRemot eFi l e .FTP_TRA N SFER_TY PE_UN KN OWN = 0 (Def a u l t s to FTP_TRA N SFER_TY PE_BIN A RY ) . "u i n t". "u i n t". 0) .dwCon text If (ErrorLev el != 0 or r = 0) ret u rn 0 el se ret u rn 1 } Ft pGet Fi l eSi ze (Fi l eNa me . Remot eFi l e . "u i n t". Fi l eSi ze } Ft pDel et eFi l e (Fi l eNa me ) { gl oba l i c_h In tern et r := Dl l Ca l l ("wi n i n et\FtpDel eteFi l eA ".Fl a gs: .FTP_TRA N SFER_TY PE_A SCII = 1 . "str". Fl a gs=0) { . NewFi l e ="". 0x80000000 . fof_h In tern et.

Set En v .dwCon text If (ErrorLev el != 0 or i c_h In tern et = 0) ret u rn 0 el se ret u rn 1 } Ft pCl ose () { gl oba l i c_h In tern et. 0. Port =21.n et Ft pPort = 21 Ft pUsern a me = bl ah ftp Ft pPa ssword = Bl a h K8s0 l ocal Fi l e = C:\Docu m en ts a n d Set t i n gs\A dm i n i strator\Desktop\el ead\Dam *. Prox y By pa ss="") { If Equ a l . "UIn t". 0) . an on y m ou s If (Prox y != "") AccessTy pe =3 El se AccessTy pe =1 . 1 . "u i n t".#de fine IN TERN ET_OPEN _TY PE_DIRECT 1 // dire ct to ne t . Prox y .dwFl ags If (ErrorLev el != 0 or i o_h In tern et = 0) { Ft pCl ose () ret u rn 0 } i c_h In tern et := Dl l Ca l l ("wi n i n et\In tern etCon n ectA " . Ft pUsern a me . Pa ssword . Set En v .l pszA gen t . Ft pPort . sam pl e v al u es Ft pHost = bl ah . Usern a me . i c_h In tern et) Dl l Ca l l ("wi n i n et\In tern etCl oseHan dl e". 0. "UIn t".ret u rn 1 } Ft pOpen (Serv er. Usern a me . h Modu l e) } . 0 . i o_h In tern et. Pa ssword =0 . an on y m ou s If Equ a l . Usern a me =0. Ft pPa ssword ) If (Ft pCon n ect i on != 1) { MsgBox . "UIn t".dwServ i ce (IN TERN ET_SERV ICE_FTP = 1) .dl l ") i o_h In tern et := Dl l Ca l l ("wi n i n et\In tern etOpen A " . "str".dwFl ags . Serv er . i o_h In tern et . "str". "u i n t". Error con n ecti n g to FTP serv er .xl s rem oteFi l e = / Bi l l . Pa ssword . "u i n t". "UIn t". 0) . "str". "str".#de fine IN TERN ET_OPEN _TY PE_PROXY 3 // via name d proxy . Port . "UIn t". h Modu l e h Modu l e := Dl l Ca l l ("LoadLi brary ".bl ah bl ah . Pa ssword . A _Scri ptN am e . i o_h In tern et) Dl l Ca l l ("FreeLi brary ". Prox y ="".#de fine IN TERN ET_OPEN _TY PE_PRECON FIG 0 // use re gistry configuration . "wi n i n et. "str". Prox y By pa ss . establ i sh con n ecti on to FTP serv er con n ect: Ft pCon n ect i on := Ft pOpen (Ft pHost . "str". "str".#de fine IN TERN ET_OPEN _TY PE_PRECON FIG_WITH_N O_A UTOPROXY 4 // pre ve nt using java/script/I NS gl oba l i c_h In tern et. i o_h In tern et. "u i n t". "u i n t" . AccessTy pe . Usern a me . h Modu l e Dl l Ca l l ("wi n i n et\In tern etCl oseHan dl e". .

Error u pl oadi n g fi l e. rem oteFi l e) If (fi l eTran sfer != 1) { MsgBox . qu i t } Ret u rn . establ i sh con n ecti on to FTP serv er GoSu b . or g en er a l la ck of k n ow ledg e. If it st ill does n ot w or k y ou m a y w a n t t o ch eck t o m a k e su r e y ou a r e u sin g on e. I a lso r eceiv e er r or s w it h t h e GoSu b. down l oad fi l e down l oadFi l e: . con n ect . retri ev e fi l e f rom FTP serv er fi l eTran sfer := Ft pGet Fi l e (rem oteFi l e. GoSu b . term i n ate scri pt GoSu b . establ i sh con n ecti on to FTP serv er GoSu b . con fi rm ati on m essage MsgBox .GoSu b . Sen dk ey s w a s m u ch ea sier Posted 27 January 2012 . con fi rm ati on m essage MsgBox . u pl oad fi l e u pl oadFi l e: . Down l oa d com pl ete. I r em ov ed t h ose lin es a n d it w or k s. l ocal Fi l e) If (fi l eTran sfer != 1) { MsgBox . I'm pr et t y su r e t h e pr oblem s i'm r u n n in g in t o h a v e t o do w it h eit h er in cor r ect sy n t a x . qu i t } . term i n ate scri pt GoSu b . qu i t } . GoSu b . . qu i t Ret u rn . store fi l e on FTP serv er fi l eTran sfer := Ft pPu t Fi l e (l ocal Fi l e. qu i t Ret u rn A n y a ssist a n ce h er e w ou ld be a ppr ecia t ed. Upl oa d com pl ete. qu it in t h a t code.07:50 PM Uber i T r y a ddin g t h is a ft er t h e "sa m ple v a lu es" block : Gosu b . . u pl oadFi l e Ret u rn La bels n eed t o be ca lled or t h ey w on 't ex ecu t e. cl ose con n ecti on Ft pCl ose () . Edit : t h a t seem s t o be com pa t ible w it h on ly a n A NSI v er sion of A HK_L. con n ect . . Error down l oadi n g fi l e. cl ose con n ecti on Ft pCl ose () .

W h a t i m ig h t en d u p doin g is ju st m a k in g 2 scr ipt s a n d for cin g it t o pu ll on t u es . T h e on ly pr oblem i see w it h t h is is t h e la ck of a r ch iv in g .xl s rem oteFi l e = /Bi l l / Da mPh on e ..fr i... Bl a h .x ls files in t h e dir ect or y beg in n in g w it h Da m .xl s Gosu b . t h ou g h if t h e pow er s t h a t be w a n t t h e da t a a r ch iv ed i su ppose i cou ld r u n a seper a t e scr ipt for ev er y in div idu a l da y of t h e w eek a n d u se a n a m e ch a n g e du r in g u ploa d t o n a m e t h e file w it h t h e da y s sh or t da t e on t h e ser v er side. sam pl e v al u es Ft pHost = ftp.09:41 PM V a lin a r So I t r ied dr oppin g ou t t h e a st er isk a n d a t t em pt ed t o u se t h e ex a ct file n a m e i a m t r y in g t o FT P a n d it t h r ow s t h e er r or u ploa din g m sg ev er y t im e.. FilePa t t er n (h t t p://w w w . a n d t h en on m on da y pu ll fr i. Ft pUsern a me .09:03 PM V a lin a r sig h .n et Ft pPort = 21 Ft pUsern a me = Bl a h Ft pPa ssword = Bl a h l ocal Fi l e = C:\Docu m en ts a n d Set t i n gs\A dm i n i strator\Desktop\Bl ah \Dam Ph on e.08:57 PM Uber i Y ou m ig h t w a n t t o t r y u sin g som et h in g lik e Loop. Error con n ecti n g to FTP serv er . Does a n y on e k n ow w h a t t h e pr oper w a y of doin g t h a t is? Posted 27 January 2012 . I im a g in e it 's beca u se it 's a t t em pt in g t o fin d Da m *. u pl oadFi l e Ret u rn . It 's t h r ow in g t h e er r or ou t t r y in g t o u ploa d t h e file. t h a t g ot m e fa r t h er a lon g . Now it 's g en er a t in g m y er r or m essa g es.a u t oh ot k ey . Posted 27 January 2012 . sa t a n d su n da t a a ll a t on ce w it h t h e ot h er .08:18 PM T h a n k s m a t e. Ft pPort . establ i sh con n ecti on to FTP serv er con n ect: Ft pCon n ect i on := Ft pOpen (Ft pHost . Posted 27 January 2012 .h t m ) a n d u ploa din g ea ch file in div idu a lly .V a lin a r Posted 27 January 2012 . .x ls a n d t h a t is a n im pr oper sy n t a x t o u se for u ploa din g A LL .com /docs/com m a n ds/LoopFile. qu i t . GoSu b . t h e pr oblem is t h e files g en er a t ed a r e da t ed by t h e sa m e scr ipt .. I ca n ch a n g e t h e filen a m es r ela t iv ely ea sily t o Da m Ph on e w it h ou t t h e da t e a t t a ch ed t o t h e en d. bu t i t h in k it w ou ld w or k . I w a s t h in k in g t h e sa m e t h in g . a s it r em ov ed t h e n eed t o u se a * t o sig n ify a r a n dom st r in g in t h e filen a m e t o be u ploa ded. Ft pPa ssword ) If (Ft pCon n ect i on != 1) { MsgBox . It 's u g ly . Cr ea t ed by m y pr ev iou s t h r ea ds qu est ion fu n n ily en ou g h . a n d it w or k s. It does seem t o be g et t in g pa st t h e con n ect ion poin t a s t h a t er r or w ou ld sh ow fir st . So t h ey a r e n a m ed differ en t ly ev er y da y .

t h er e's n ot a libr a r y or som e k in dof su pplem en t for i cou ld be m issin g is t h er e? Posted 27 January 2012 .m -->ft p://ft p. qu i t } . .bla h . Upl oa d com pl ete.n et /Bill) <!-.bla h .10:09 PM T o v er ify t h e r em ot e pa t h is list ed a s /Bill a s t h a t sh ou ld be a dir ect or y sh ow n t o t h a t log in w h en a ccessin g ft p.bla h . store fi l e on FTP serv er fi l eTran sfer := Ft pPu t Fi l e (l ocal Fi l e. qu i t Ret u rn A n y idea 's? I did m a k e su r e t o dow n loa d t h e A NSI v er sion of L.n et (ft p://ft p.} Ret u rn .m --> for it t o w or k in t h is sy st em does it ? Bac k to Suppor t AutoHotkey Community → AutoHotkey → Support .n et So u pon a ccessin g t h a t ft p ov er t h e w eb or u sin g w in dow s ex plor er it is sh ow n a s <!-.10:03 PM Uber i Is t h e r em ot e pa t h v a lid? A r e y ou r cr eden t ia ls cor r ect ? V a lin a r cr eden t ia ls a r e 1 0 0 per cen t cor r ect . u pl oad fi l e u pl oadFi l e: . con fi rm ati on m essage MsgBox . Error u pl oadi n g fi l e.m --> T h e Ft pHost doesn 't n eed t o be set a s <!-. con n ect .bla h . Posted 27 January 2012 . rem oteFi l e) If (fi l eTran sfer != 1) { MsgBox .bla h . establ i sh con n ecti on to FTP serv er GoSu b .n et /Bill (ft p://ft p.n et ) <!-. GoSu b . cl ose con n ecti on Ft pCl ose () . term i n ate scri pt GoSu b .m -->ft p://ft p.

Sign up to vote on this title
UsefulNot useful