Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

FileSystemObject

Posted on 2001-06-26
32
Medium Priority
?
359 Views
Last Modified: 2012-06-21
HI

I am trying to run the below code:

Dim objXMLHTTP, xml

Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", "http://webserver/magazine1/index.asp", False
xml.Send
value =  xml.responseText
Set xml = Nothing


Set objFile = Server.CreateObject("Scripting.FileSystemObject")
Set objTStream = objFile.OpenTextFile(Server.MapPath("indexof.htm"), 2, True, 0)
objTStream.Write(value)
 
Set objFile = nothing

and I getting the following error :

Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument

/magazine1/inco.asp, line 32

the line 32 is the one that has the line :objTStream.Write(value)

if I do a response.write(value) it prints all the HTML retrieved but it is not able to write to the HTML file I checked if the file is found ? it is found and I do have permissions !!!!

Please help
0
Comment
Question by:marounk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 16
  • 8
  • 3
  • +3
32 Comments
 
LVL 20

Expert Comment

by:jitganguly
ID: 6227793
Use writeline

objTStream.WriteLine value
 
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6227896
Hmm it should work actually..

try to change the value to something else for testing.. like "xyz"

also set the permissions to full controle.. fso sometimes chokes for less..
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6227907
2cents: If nothing works try to write to the stream by chunks..
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 20

Expert Comment

by:jitganguly
ID: 6227924
Actually try this also
Instead of this line

Set objTStream = objFile.OpenTextFile(Server.MapPath("indexof.htm"), 2, True, 0)

use constants, like

Set objTStream = objFile.OpenTextFile(Server.MapPath("indexof.htm"), ForWriting, True, TristateFalse)
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6227929
>use constants, like

Set objTStream = objFile.OpenTextFile(Server.MapPath("indexof.htm"), ForWriting, True, TristateFalse)

He'll need to include the adovbs.inc ... it's the same, better to do as he did..
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6227932
>use constants, like

Set objTStream = objFile.OpenTextFile(Server.MapPath("indexof.htm"), ForWriting, True, TristateFalse)

He'll need to include the adovbs.inc ... it's the same, better to do as he did w/o constant names..
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6227943
The IUSR_Webservername is the one that you should grant full permissions to the file, if anonymous account is enabled..
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6228046
try:

Call objTStream.Write(value)

or

objTStream.Write value
0
 
LVL 2

Expert Comment

by:preinsko
ID: 6229807
Unless something changed recently xmlhttp returns a xml stream.  Typically the reponse content is written to a data island.

strOutputResponse = objXMLReq.responseText

in the body of html document
<p>Response XML:</p>
<div id=divOutputResponse><%=strOutputResponse%></div>
There is a sample in the xml sdk.

0
 
LVL 14

Expert Comment

by:puranik_p
ID: 6229990
the error you are getting .. "Invalid procedure call or argument " appears in these cases..
1. you are using parantheses for a procedure call
(exactly thats what you are doing.!)
objTStream.Write(value) will cause error.
objTStream.Write value  will work.

2. you are calling the function with more than or less than number of arguments.
(which is not the case with you.)
so relax!!

 
0
 
LVL 1

Author Comment

by:marounk
ID: 6230119
Thnx all for replying but nothing worked !

If I write for example a string "hello world" it works but when I try to write the variable "value" it does not.

I gave the I_user permissions to the whole directory but still no sign of life


silvers5 could you please explain how to write chunks ???
or is there any other altenative ?

0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6230123
everything looked ok except for how you called the function with parentheses...at least, that is something you NEED to fix because it should be generating an error.
0
 
LVL 1

Author Comment

by:marounk
ID: 6230135
would it help if you knew that the data size :30287
I did  a Response.write(len(value)) it returned 30287 !!!

I think the problem is with the size of Data because when I run objTStream.Write "hello world" it worked !!!!
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6230151
thats near the integer data type limit, so perhaps that is an issue...

>>when I run objTStream.Write "hello world" it worked

also notice you properly called the method here.  try each of the following:

Call objTStream.Write(value)
objTStreamWrite value
Call objTStream.Write(Left(value, 20000))
objTStream.Write Left(value, 20000)

just to see if it is indeed size that is hurting you.
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6230179
by chunks..
Set objTStream = objFile.OpenTextFile(Server.MapPath("indexof.htm"), 8, True, 0) '8 is for appending

ZLength = Len(value)
for x = 1 to ZLength
valueX = Mid(value,x,3000)
x = x + 3000
objTStream.Write(valueX)
next
valueX = right(value,ZLength - (ZLength MOD 3000)
'the above line will write the last chunk that was bypassed, if it's less than 3000 characters, MOD returns the remainder of a division between 2 numbers
objTStream.Write(valueX)
....


rgrds
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6230183
errata:
valueX = right(value,ZLength - (ZLength MOD 3000)

should have a closing parantheses and like this

valueX = right(value,(ZLength MOD 3000))
0
 
LVL 2

Expert Comment

by:preinsko
ID: 6230217
Silvers5 stated this before!!
The IUSR_Webservername must have write permissions. I notice that what you say regarding permissions is
>>it is found and I do have permissions !!!!
Here you stated I do have permissions not that the web server has permissions.

It makes no difference if you have permissions unless your application is using NT Authentication.

I just took your code and added to a xmlhttp page I happened to have, and wrote to a folder I have setup for writing to.  The response from the remote server was written to the file with no problem. So there is nothing functionally wrong with your code. The only thing left is permissions.

Please go to the folder in question
Right click
Select the security tab
Look at the list and see if there is an entry for
IUSR_WebServerName  WebServerName should be the name of your web server.
If there is check the permissions, write permissions are not given by default (normally) if the write checkbox is off put a check there.
If the IUSR_WebServerName does not appear in the list then add it and give it write permissions.
Select Apply and run your app I think it will work now.
If it works please give the points to Silvers5 since he twice mentioned permissions to you.  

Hope this helps because I am totally stumped on this one.




0
 
LVL 1

Author Comment

by:marounk
ID: 6230222
Check this out :

I have tried the following :
objTStream.Write Left(value, 5000) it worked , then I tried objTStream.Write Left(value, 10000) it failed and it gave the error it seems that it can not write huge blocks of data !

0
 
LVL 1

Author Comment

by:marounk
ID: 6230233
Hi Preinsko
I already gave permissions to the I_user to full control but it did not change ! the problem is with the amount of data written .thnx for your help

0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6230262
maroun, I posted you a code on how to do it.. you can add it in a function for repeated reusability..

rgrds
0
 
LVL 1

Author Comment

by:marounk
ID: 6230290
silvers5

I used your code and it failed on a point !!! it wrote like 10 % to the file then it failed then I tried to do the following :

objTStream.Write Left(value, 6100) it worked
objTStream.Write Left(value, 6200) it worked
objTStream.Write Left(value, 6300) it worked
objTStream.Write Left(value, 6400) it failed !!
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6230293
or is it Tarek ;o)
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6230304
Try it like this:

appending will be needed here.. not in the previous code..

ZLength = Len(value)
for x = 1 to ZLength
Set objTStream = objFile.OpenTextFile(Server.MapPath("indexof.htm"), 8, True, 0) '8 is for appending
valueX = Mid(value,x,6000)
x = x + 6000
objTStream.Write(valueX)
Set objStream = nothing
next
Set objTStream = objFile.OpenTextFile(Server.MapPath("indexof.htm"), 8, True, 0)
valueX = right(value,ZLength - (ZLength MOD 6000)
'the above line will write the last chunk that was bypassed, if it's less than 6000 characters, MOD
returns the remainder of a division between 2 numbers
objTStream.Write(valueX)
Set ObjStream = nothing
....



0
 
LVL 1

Author Comment

by:marounk
ID: 6230373
fails too ~!!! this problem is driving me nuts ~~
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6230392
what's the error now?
0
 
LVL 1

Author Comment

by:marounk
ID: 6230393
I know where the problem is :

it is failing on strange chracters , the asp file is reading french data from the Database the write is failing on the character e if I change it e it will continue to write until another french specific character where it fails!

0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6230396
can you post the url you're fetching? or email it to silvers@rocketmail.com(if it's on the web)
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6230410
hmm.. try to use the french codepage

0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6230448
<%@ Language=VBScript Codepage=ISO-8859-1%>
0
 
LVL 1

Author Comment

by:marounk
ID: 6230480
Active Server Pages error 'ASP 0203'

Invalid Code Page

/magazine1/inco.asp, line 1

The specified code page attribute is invalid.
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6230495
When you response.write value are the french characters prserved (then no need for the code page)


try also:
value=server.HTMLEncode(value)  

before writing to the file
0
 
LVL 20

Accepted Solution

by:
Michel Sakr earned 200 total points
ID: 6230511
although it might garble the output...

http://support.microsoft.com/support/kb/articles/q259/3/52.asp

you can also replace the french characters:

value=replace(value,"e","&#130") 'e = e with accent aigu /

do it to all the french characters you can find their ascii dec values here http://members.tripod.com/~plangford/ or by using the asc function

rgrds
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question