Link to home
Start Free TrialLog in
Avatar of calven
calven

asked on

How to write file to server using FSO?

I want to write a file into a server called "XYZ" and I have already mapped it as P: in my system and my system is the Web Server (IIS 5.0) using Win2K Pro.

The problem I found is that, the ASP keep on saying "Path not found".

I saw the method that suggested by microsoft but since this is the first time I am using IIS to run my script, so I do not know how to configure the IIS to let it execute my script correctly and write files to the server.

Anybody can give me a step by step guide? Thanks.
Avatar of calven
calven

ASKER

By the way, I have read the article posted in the microsoft and I am still a bit blur about it. Please help. Thanks.
--> mapped it as P:
Is the folder in your web server machine or in other computer?
post your code, it will help us to analyze your problem better. :)
Where are you writing to? In your local drive? Like...
<%
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Set ts = ObjFSO.CreateTextFile("C:\Temp\XYZ.txt")
ts.writeline("this")
ts.close
Set objFSO = nothing
%>

This will work...

Try writing down your pass and see where it is going..

like..
sFilePath = "brah Brah Brah..."
Response.write sFilePath
Response.end

Make sure that path exists
Avatar of calven

ASKER

 dim PilotServer
 
  PilotServer = "P:"

  myPath=PilotServer & "\HOME"

 
    set fs = server.CreateObject ("Scripting.FileSystemObject")
if not fs.FolderExists (myPath) then
fs.CreateFolder (myPath)
end if
set fs=nothing
 
set fs=server.CreateObject ("Scripting.FileSystemObject")
set outfile = fs.CreateTextFile (myPath & "\parts", TRUE)
outfile.writeline ("This is a test")
outfile.close
set fs=nothing

Above is my code. I want to create a folder in the server and this server is running novell software. And after creating the folder i will proceed on to create a file in that path but the error is "Path not found".

Thanks for your help.

the if ... then... always cannot find the myPath and when the script reach fs.CreateFolder (myPath)
Where do you map that folder? On your computer, or on your webserver machine?

Never tested it before, but I think it will work if you map the folder on the webserver machine instead of your computer.

I assume that your ASP file will be executed on your server, not on your computer.
Avatar of calven

ASKER

I map that folder to the pilot server (not my computer). And the webserver is my PC. The situation is my PC is a webserver running IIS 5.0 when my colleagues access my the web site (ASP site; in my webserver) they will use my ASP application to generate some document (files) to the pilot server.

Means my PC (Webserver) will act as a middle man to help them create files to the pilot server. That's why I want to "write" files across network.

Thanks for you help again.
Hmm...
Let me try to understand it correctly:

Your web server is creating the file and that file has to be sent to the pilot server (other computer)?

I think it is related with the permission issue.

Try to read this article:
http://www.webdevelopersjournal.com/articles/filesystemobject.html

Hopefully, it will give you clearer understanding.

Another solution is using automation uploading file to the Pilot server. You can use ASPSmartUpload (http://www.aspsmart.com/) to do this.
Let me know if you need help on doing this.

Cheers,

Daniel
Avatar of calven

ASKER

I map that folder to the pilot server (not my computer). And the webserver is my PC. The situation is my PC is a webserver running IIS 5.0 when my colleagues access my the web site (ASP site; in my webserver) they will use my ASP application to generate some document (files) to the pilot server.

Means my PC (Webserver) will act as a middle man to help them create files to the pilot server. That's why I want to "write" files across network.

Thanks for you help again.
Novell and windows are really bad as far as interacting goes, make sure that the IUSR account is created and passwords are synched in the windows and novell network, also, you have to remember that IIS is running as a service so it will not have access to a mapped drive, use a unc path.  Also, make sure that the NWGS service account is synchronized with the novell side...
Avatar of calven

ASKER

Besides settings the IUSR account for IIS. Do i have any other methods, roads to do it. As the link given by Daniel, the article said that there might be a security problem.
I'm not quite sure what you mean...do you mean other methods besides FSO to accomplish your solution??
Avatar of calven

ASKER

Yes, besides using FSO what method can I use?
You could use MS Message Queueing....Have your pages post a message to the message queue and have another application monitor the queue and create the files as necessary...or...if you don't need the physical files available, you can write blobs into SQL or Access...or...your use FSO to write to the web server locally and create another app that moves it from the web server to its final destination
Hi Calven,

Guess what? I copied your code above and ran it on my test web server. EVERYTHING WORKED! Initially, I got problems concerning permissions but after performing a few adjustments on the file system permissions, I was able to generate the parts file and the home directory.

There are however certain differences on our setup equipment. My web server is running Windows 2000 Advanced Server and the pilot server you referred above is running Windows 2000 Professional in my situation. I believe your configuration is this: web server is Windows 2000 Professional and your pilot server is running something else... (didn't quite get the OS it's running on.)

Anyway, what line does the error occur? You should see this when you get the "Path not found" message. Also, have you tried _directly_ writing files to your pilot server via the P: mapping? Try creating a text file on your P: drive using your Windows 2000 Professional machine via Windows Explorer, File Manager, etc. as long as it's not via the ASP script above.

There might be problems with how Windows 2000 Professional connects or accesses services from a server running Novell software.

Let us know what you find.

Thanks!
Melio
ASKER CERTIFIED SOLUTION
Avatar of Michel Sakr
Michel Sakr
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or, since it is under your webserver machine, why don't you give permission to your friend to browse the directory, so that he can download the files themselves?
Avatar of calven

ASKER

Melio,

I tried to do it in another PC (let's call it X) with this code:
<%
  set fs=server.createobject ("Scripting.FileSystemObject")
  myPath="P:\"
  if fs.folderexists (myPath) then
    response.write myPath & " Exist!"
  else
    response.write myPath & " Not Exist"
  end if

%>

and it works just nice.

I shared a folder (Songs) in X and then try to map a drive called P:\ to this path \\x\songs. The permission to access the share name "songs" is "Everyone". And I got it work. By the way, X is using Windows 2K pro and IIS5.0 (same as my webserver machine).

But when I tried the same code in my webserver machine, the problem is "myPath" not exist. Means in the webserver, it always cannot even detect the folder.

I really don't know what's wrong already. Please advice. Thanks.
Avatar of calven

ASKER

Sorry, to clarify something. My webserver machine can detect local folder but not mapped folder like P: or T: or whatever mapped drive. Please help, I really confuse at this point.

Is it because my webserver machine is joining domain instead of joining workgroup. And the PC X is a standalone PC (without joining any domain or workgroup) and I logged in PC X with "administrator" account. But I logged in to my webserver as domain user (not admin)?
I told you how to overcome this.. also I told you hoe to let the code view the maping (you can use a UNC instead also)  so read and implement correctly as I said (or similarly)
Avatar of calven

ASKER

Thanks Silvers5.
I found out that if i install PWS or even IIS in a PC that did not register / join to any domain, the script is able to find the network path such as \\myserver\home.

If I tried the script run at a server that joined in the domain, it can't detect the network path such as \\myserver\home.

How do I make it run? If I need to set the IUSR stuff, like you said, I will need to contact my domain controller's admin, rignt?

And this is the script I used to detect the network path:
<%
  set fs=Server.CreateObject ("Scripting.FileSystemObject")
  myPath="\\myserver\home"
  if fs.FolderExists (myPath) then
    response.write myPath & " Exist"
  else
    response.write myPath & " Not exist"
  end if
%>

Thanks for your help again.
>If I need to set the IUSR stuff, like you said, I will need to contact my domain
controller's admin, rignt?

right.. nothing can be done without them..

         No comment has been added lately, so it's time to clean up this TA.
         I will leave a recommendation in the Cleanup topic area that this question is:
         Accept Silvers5's comment as amswer.
         Please leave any comments here within the next seven days.
         
         PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
         
         puranik_p
         EE Cleanup Volunteer  
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange