Page 2 of 2 <12
Topic Options
#154441 - 06/01/10 01:19 AM Re: ftp exist udf?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 01/06/05
Posts: 22294
Loc: Claremore, OK
to make a completely unique string per request, one should use time tags.
example:
$req.open("GET", "xmlprovider.php?hash=" + @date + @time)
_________________________
!

download KiXnet

Top
#154442 - 06/01/10 01:24 AM Re: ftp exist udf?
Shawn Administrator Offline
Administrator
*****

Registered: 99/08/13
Posts: 8606
ja, cant test it much but it does seem to at least see past the hash-stuff, and download the file ... hopefully the most recent version ;0)

FTPget("ftp://ftp.mcafee.com/CommonUpdater/delta.ini?hash=+@date + @time","e:\delta.ini")

Top
#154443 - 06/01/10 02:05 AM Re: ftp exist udf?
Shawn Administrator Offline
Administrator
*****

Registered: 99/08/13
Posts: 8606
btw - anyone catch that fancy word in that quote above ... non-idempotent ... don't know wtf that means, sounds like some kind of medical condition I don't want to catch.
Top
#154444 - 06/01/10 04:02 PM Re: ftp exist udf?
cyri Offline
Getting the hang of it

Registered: 05/06/27
Posts: 95
I tried this code.
Code:
FTPget("ftp://ftp.mcafee.com/CommonUpdater/delta.ini?hash=+@date + @time","e:\delta.ini")



But it's not downloading the file now. Am I missing something?

Top
#154445 - 06/01/10 04:10 PM Re: ftp exist udf?
Shawn Administrator Offline
Administrator
*****

Registered: 99/08/13
Posts: 8606
nah, it was just a shot in the dark.
Top
#154446 - 06/01/10 04:24 PM Re: ftp exist udf?
Jochen Moderator Offline
KiX Supporter
*****

Registered: 00/03/17
Posts: 6197
Loc: Stuttgart, Germany
Shawn : Wiki entry for idempotent
_________________________
I cna ytpe 300 wrods pre mniuet!!

Kixforms forum.

Top
#154447 - 06/01/10 04:54 PM Re: ftp exist udf?
Shawn Administrator Offline
Administrator
*****

Registered: 99/08/13
Posts: 8606
Thanks cappy - I'm having a hard time even pro-nouncing that word, without like - spitting all over my monitor.

Anyone want to comment / take a stab at writing a POST request version of FTPGet ?

Top
#154448 - 06/01/10 05:10 PM Re: ftp exist udf?
cyri Offline
Getting the hang of it

Registered: 05/06/27
Posts: 95
I'm still playing with this hash used in the first method (below).
req.open("GET", "xmlprovider.php?hash=" + Math.random());

The third method (shown below) I tested and it still grabbed the old copy of the file.
req.open("GET", "xmlprovider.php");
req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
req.send(null);

As for attempting to write a modified UDF. I think thats a bit out of my skill range. I'm not familar enough with XMLHTTP.

Top
#154449 - 06/01/10 07:23 PM Re: ftp exist udf?
NTDOC Administrator Offline
Administrator
*****

Registered: 00/07/28
Posts: 11545
Loc: CA
And modifying the .DefaultUser profile didn't work?
Top
#154450 - 06/01/10 07:30 PM Re: ftp exist udf?
Shawn Administrator Offline
Administrator
*****

Registered: 99/08/13
Posts: 8606
Quote:


It has built in credentials in the task. Would this still apply?





You mean to say the task is running under a user account ? If so, might also try (as a test) a scripted DEL of temporary internet files - just as a test I mean. At least you would know for sure whether caching was the issue.

Top
#154451 - 06/01/10 07:32 PM Re: ftp exist udf?
cyri Offline
Getting the hang of it

Registered: 05/06/27
Posts: 95
I feel a little sheepish. I got a bit involved in some of the other posts that I didn't even try it...until now. Your reg hack worked NTDOC. Thank you for that.

Though I'm sure there is probably a way to do this within XMLHTTP as well without modifying IE settings.

Top
#154452 - 06/01/10 09:37 PM Re: ftp exist udf?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 01/06/05
Posts: 22294
Loc: Claremore, OK
the post version of ftpGet is no biggie.
just change the send() to have some sh*t in it:
send("hash=sh*t")
_________________________
!

download KiXnet

Top
#154453 - 06/01/10 10:43 PM Re: ftp exist udf?
Shawn Administrator Offline
Administrator
*****

Registered: 99/08/13
Posts: 8606
ok so try this POST version of FTPGet then ...

Code:

Function FTPget($sURL, $sTargetFile, optional $sUser, optional $sPass)
Dim $oFTP, $oStream
$sUser=""+$sUser
$oFTP = CreateObject("Microsoft.XMLHTTP")
if @error $ftpget=1 exit 1 endif
$oStream = CreateObject("ADODB.Stream")
if @error $ftpget=2 exit 2 endif
if $sUser
$oFTP.Open("POST", $sURL, not 1, $sUser, $sPass)
else
$oFTP.Open("POST", $sURL, not 1)
endif
if @error $ftpget=3 exit 3 endif
$oFTP.Send
$oStream.Type = 1
$oStream.Mode = 3
$oStream.open
$oStream.Write($oFTP.responseBody)
if @error $ftpget=4 exit 4 endif
$oStream.SaveToFile($sTargetFile, 2)
if @error $ftpget=5 exit 5 endif
$oStream.Close
EndFunction



-Jaffa

Top
#154454 - 06/01/10 11:44 PM Re: ftp exist udf?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 01/06/05
Posts: 22294
Loc: Claremore, OK
no...
you didn't even touch the send method.

hmm...
on the other hand, we don't have anything really to send.
did you didn't try this out yourself?
_________________________
!

download KiXnet

Top
#154455 - 06/01/10 11:47 PM Re: ftp exist udf?
Shawn Administrator Offline
Administrator
*****

Registered: 99/08/13
Posts: 8606
Make it go.
Top
#154456 - 06/01/10 11:53 PM Re: ftp exist udf?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 01/06/05
Posts: 22294
Loc: Claremore, OK
k, checked out the syntax and this should work for you:
Code:

Function FTPgetPOST($sServer, $sFile, $sTargetFile, optional $sUser, optional $sPass)
Dim $oFTP, $oStream
$sUser=""+$sUser
$oFTP = CreateObject("Microsoft.XMLHTTP")
if @error $ftpget=1 exit 1 endif
$oStream = CreateObject("ADODB.Stream")
if @error $ftpget=2 exit 2 endif
if $sUser
$oFTP.Open("POST", $sServer, not 1, $sUser, $sPass)
else
$oFTP.Open("POST", $sServer, not 1)
endif
if @error $ftpget=3 exit 3 endif
$oFTP.setRequestHeader = "Content-Type", "application/x-www-form-urlencoded"
$oFTP.Send($sFile)
$oStream.Type = 1
$oStream.Mode = 3
$oStream.open
$oStream.Write($oFTP.responseBody)
if @error $ftpget=4 exit 4 endif
$oStream.SaveToFile($sTargetFile, 2)
if @error $ftpget=5 exit 5 endif
$oStream.Close
EndFunction

_________________________
!

download KiXnet

Top
#154457 - 06/01/10 11:56 PM Re: ftp exist udf?
Shawn Administrator Offline
Administrator
*****

Registered: 99/08/13
Posts: 8606
Cool. By the way, I did try out the other one and it does download the file, but I cant really tell about the cache stuff. Plus your code looks like you put more thought into it ...
Top
#154458 - 06/01/11 12:00 AM Re: ftp exist udf?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 01/06/05
Posts: 22294
Loc: Claremore, OK
but I didn't
just ripped some source from bbChecker
_________________________
!

download KiXnet

Top
#154459 - 06/01/11 12:45 AM Re: ftp exist udf?
NTDOC Administrator Offline
Administrator
*****

Registered: 00/07/28
Posts: 11545
Loc: CA
Well glad you got it going Cyri, but looks like all of us got a little something more and learned a bit more from this thread so that's cool too.

Thanks Shawn and Jooel for the UDF code.
 

Top
Page 2 of 2 <12


Moderator:  Jochen, Allen, Radimus, Chris S., Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 113 anonymous users online.
Newest Members
schnuggel, h315060, johnnyutah, pmk31, ArserHsieh
17412 Registered Users

Generated in 0.04 seconds in which 0.01 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org