Wednesday, September 10, 2008

Grab HTML source code from website, save it to file


<!--#include file="../include/myFunctions.asp"-->
<%
Dim strHTML

Dim fileNameToSave
Dim linkToGrab

fileNameToSave = "D:\Sites\Danny_Testing\tmp\test.txt"
linkToGrab = "http://192.168.100.236/tmp/test.html"

updateFileFromWeb fileNameToSave, linkToGrab ' call the updateFileFrom

Function updateFileFromWeb( fileNameToSave, linkeToGrab )
lastModifiedDate = ShowDateModified( fileNameToSave )
currentDate = Now()

If DateDiff("n", lastModifiedDate, currentDate) > 1 Then ' If the file is one day old, we update it with new content from FirsTrade website (FirstTrade).
strHTML = GrabHTMLPageV1( linkToGrab )

strHTMLResult = ParseBlockString(strHTML,"<!--NAIStart-->", "<!--NAIEnd-->") ' We use the html comment tag for parsing the data.

writeToFile strHTMLResult, fileNameToSave ' Write to file

'Response.Write strHTMLResult
Response.Write "the file just updated."
End if
End Function

Function ShowDateModified(filespec)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
ShowDateModified = f.DateLastModified
End Function

Function ShowDateCreated(filespec)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
ShowDateCreated = f.DateCreated
End Function

Sub writeToFile( str, fileName )
Dim Stuff, myFSO, WriteStuff, dateStamp
dateStamp = Date()

Set myFSO = CreateObject("Scripting.FileSystemObject")
Set WriteStuff = myFSO.OpenTextFile( fileName, 2, True)

WriteStuff.WriteLine( str )
WriteStuff.Close

SET WriteStuff = NOTHING
SET myFSO = Nothing
End Sub

Function ParseBlockString( strFull, strStart, strEnd )
strStartPosition = InStr(1, strFull, strStart)
strEndPosition = InStr(1, strFull, strEnd) + Len(strEnd)

strLength = strEndPosition - strStartPosition // The length between the strStart to strEnd

if strStartPosition = 0 Or strEndPosition = 0 Then
ParseBlockString = "One of Strings (strStartPosition, strEndPosition) not found!"
ElseIf strLength < 1 then // It is not right if the the strStartPosition is bigger than strEndPosition, coz strStartPosition should come first, then strEndPosition comes next.
ParseBlockString = "One of Strings (strStartPosition, strEndPosition) not found!"
Else
ParseBlockString = Mid(strHTML, strStartPosition, strLength)
// ParseBlockString = Server.HTMLEncode( Mid(strHTML, strStartPosition, strLength) ) ' If you would like to encode the html code, use this line
End if
End Function


Function GrabHTMLPageV1(strURL) ' This one works for older ASP
Dim objXmlHttp
Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXmlHttp.Open "GET", strURL, False
objXmlHttp.Send


If Err.Number = 0 Then
If objXmlHttp.Status = 200 Then ' Return header code must be equal to 200
strHTML = objXmlHttp.ResponseText
'GrabHTMLPageV1 = Server.HTMLEncode(strHTML) ' This is for replacing < to < and > to >
GrabHTMLPageV1 = strHTML
Else ' There is an erro
GrabHTMLPageV1 = "either Incorrect URL or " & objXmlHttp.statusText
End if
Else
GrabHTMLPageV1 = Err.Description
End If

Set objXmlHttp = Nothing
End Function

Function GrabHTMLPageV2(strURL) ' This one works for newer ASP
Dim objXML
Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET" , strURL , False ,"",""
objXML.Send

If Err.Number = 0 Then
If objXML.Status = 200 then ' Return header code must be equal to 200
GrabHTMLPageV2 = objXML.ResponseText
Else ' There is an erro
GrabHTMLPageV2 = "Incorrect URL"
End if
Else
GrabHTMLPageV2 = Err.Description
End If
Set objXML = Nothing
End Function

%>

Getting the properties and methods available with an object

Getting the properties and methods available with an object
I'm unable to instantiate TLI.TLIApplication from TlbInf32.dll

!PLEASE HELP!

The answer for how to determine the properties / methods / events

available to an object or within a .dll was/is? to use

windows\system\TlbInf32.dll by starting off like so:

Set oTLI = CreateObject("TLI.TLIApplication")

If I do this from my VBScript file, I get the error: Could not locate

automation class named "TLI.TLIApplication". Code: 80020009 Source:

WScript.CreateObject

At the same time, if I go into my VB5CCE and set Project/References to

find Typelib Information (which is located for me in

c:\windows\system32\TlbInf32.dll on my WinXP Pro, SP 2 system) and then

do:

Dim foo As TLI.TypeLibInfo

Set foo = New TLI.TypeLibInfo

MsgBox TypeName(foo)

Then VB is happy with that and the MsgBox shows: TypeLibInfo

Now, I have neither VB 5 nor the VB 6 development environment

installed. All there is, is me and my trusty VB5CCE, and version 5.6

of WScript. Just in case, I closed down VB5CCE to do the test, and I

also did

Regsvr32 c:\windows\system32\tlbinf32.dll.

After that I plied it with /u several times, then a last time without

/u, and regsvr32 was continually happy. The tblinf32.dll file itself

is dated 1/16/1997 at 132608 bytes and version 1.1.37.15

I hope someone has an idea on this cause I am stumped,

Thanks,

Csaba Gabor from Vienna

Re: Getting the properties and methods available with an object
I don't know if this will help, but you

might try checking it in an object

browser to confirm the details of the

object model. Your code should work with

the VB6 version (1.10.8169, June, 98) but

you apparently have the VB5 version, which

could be slightly different. I know that there

are incompatibilities between the two versions,

(installing v. 6 over v. 5 can reportedly cause

malfunctions in software that uses v. 5) but I

don't know what exactly those incompatibilities

are.
Re: Getting the properties and methods available with an object
ekkehard.horner wrote: 

I'd like to thank everyone for their response (Ekkehard, Mayayana, JW).

As a result, my biggest problem is solved, but there are still some

remnants which it would be good to clear up.

Ekkehard, your response reminded me that I have an old machine, and so

I looked at it and got it's TlbInf32.inf info from it. It is version

1.1.81.69 (size: 153600, with a date of 14 July 1998). I unregistered

the earlier version in c:\windows\system32 and registered the new one

(which I had in a different directory). At this point, the sample code

below ran as expected. Cool, and thanks.

Unfortunately, PHP is not so happy with this setup. Now, I can make

things work within PHP by stuffing VBScript into an

MSScriptControl.ScriptControl but that's not right.

Microsoft says that TlbInf32.dll is redistributable at:

http://msdn.microsoft.com/vbasic/downloads/addins/components/default.aspx

so I am hoping that someone will redistribute a more recent version to

me so I can see if it is PHP that is buggy, the .dll, or my

configuration.

Thanks,

Csaba Gabor from Vienna

Mayayana, thanks for the warnings - I hope that does not account for

the behaviour that I am seeing.

ASP write data to file error

Microsoft VBScript runtime error '800a0046'
Permission denied
/test/tmp.asp, line 15

Since the tmp.asp has to WRITE the file to server's file system, it is possible that the location you are trying to save uploaded file may not have WRITE permission for the user IUSR_MachineName. Please contact your website's system administrator to enable both READ and WRITE permissions for the folder where you want to keep (WRITE) uploaded files.

Note: if the error still shows up, make sure you specify the full path of the file in your script.

To output Path Info:
Response.Write Request.ServerVariables("PATH_INFO")
Response.Write Request.ServerVariables("PATH_TRANSLATED")

Windows 2000 Remote Desktop / Remote Control

Windows 2000 Remote Desktop / Remote Control

Are you trying to connect to a Windows 2000 Server? If so, go to start/settings/control panel, select add/remove programs, select add/remove windows components. Scroll down and select Terminal Services. Remote Administration mode will allow a max of 2 concurrent connections. Make sure to giv the users that need to use this the right to log on locally.

Windows 2000 workstation does not have Terminal Services remote access capabilities. You'll have to use a 2rd part remote access product.

I'm not totally certain but I think you need 2000 advance server to be able to connect with the remote desktop.
Anyway, I can recommand to try RealVNC from http://www.realvnc.com
quite good and free.

Tuesday, September 9, 2008

ASP MS SQL - Fractional Truncation error - 80004005

ASP MS SQL - Fractional Truncation error - 80004005

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC SQL Server Driver]Fractional truncation

Check if the certain field is set to "not allow null", and assign the value to the field when you are inserting data.

Monday, August 4, 2008

有關 Windows XP 換硬體 (如主機板) 會出現藍色畫面的問題

http://forum.slime.com.tw/thread98951.html 雙核心的部分自己要換核心檔案 別的地方以前有說過 不贅述

http://happywoo.blogspot.com/2008/03/winxp-ghost.html 大陸人寫的工具要不要用再說 反正驅動程式可以在安全模式移掉的都要移掉

http://www.yorkmak.com/ghost.htm 主要就是要換HAL

http://bbs-mychat.com/read.php?fid=220&tid=215589&page=1 還有安全性辨識碼的部分 所謂的sysprep

http://blog.udn.com/luckyhoo/1707042 Microsoft Windows XP 更換硬體不重裝的方式

David: 恩 關鍵字 ACPI GHOST XP 可以找到 如果真的關鍵的話 應該還要加 HAL SYSPREP

True Image Notes

True Image

1. Big parition (Source) to Small partition (destination) is okay as long as the total space of the destination parition is larger than the used space of the source partition.

2. Figure out the difference between "Acronis Bootable Agent" the boot agent and "Acronis True Image Echo Enterprise Server" (After booting from True Image's bootable CD, there are these options)

Acronis Bootable Agent is currently running. Now you can connect to this computer remotely with Acronis True Image Management Console.

3. There are three ways to convert the physical machine to the virtual machine. First way, using VMware converter to cold clone the physical machine. Second way is to use VMware converter to conver the existing *.tib file (true image) to VMware files. Third way is using the True Image built-in tool to convert it to VMware files.

4 剛試用 True Image Echo Enterprise Server with Universal Restore ,好讚

主要是嘗試 Universal Restore 這個功能,它是可以幫助 在 主機 A clone 下來的 image 拿到 主機 B or 其它 主機 上 還原 而 不會 有 藍色畫面 ( Windows XP 系統 換 硬體 / 主機板 時 會有的問題),剛試過,可以成功轉移

我分別在 physical machine and virtual machine restore 都 okay

然後 它 也可以 預先 把 想要另外載入的 drivers ( 如 RAID, SCSI, etc ) 一併包裝一起

David: 這個 就是加inf跟相關驅動程式檔案到系統目錄呀

呵,因為好多年前 曾遇過這樣的問題 (裝好系統的 硬碟 換個主機 就不能用了),然後一直沒有想把它解決,今天睡著睡著 突然 好想來試看看,才意外發現 True Image 的 Universal Restore 這個 add on 有這功能 ^^||

5. some links
http://www.autoit.tw/bbs/viewthread.php?tid=3019

Windows SRV 備援&備份

http://www.google.com/search?hl=zh-TW&q=true+image+vmware&lr=

http://www.ithome.com.tw/itadm/article.php?c=48761


.