I've run into a problem with creating an XML file on a UNIX server. I don't
have access to the server and I'm trying to create an XML file so an outside
agency can read it through the site URL.
On a Windows machine I use GetDirectoryFromPath and ExpandPath to return the
drive/path info, then I create the file with this and the query result. On the
Unix web server I am only being returned a relative path, because of this I
can't write the XML file to the web server. Any idea how to get around this?
<!--- get the path and use it to write the XML file --->
<cfset thisPath = ExpandPath("*.*")>
<cfset thisDirectory = GetDirectoryFromPath(thisPath)>
<!--- this path has to match the path of the web server --->
<cffile action="write" file="#thisDirectory#mm_fund.xml"
output="#toString(mm_fund)#">
<cfcontent type="text/xml">
<cfoutput>#toString(mm_fund)#</cfoutput>
</cfcontent>
BKBK - 14 Sep 2007 18:22 GMT
GetDirectoryFromPath and ExpandPath should work on Linux, too. Did you attempt
something like the following?
<!--- the xml file --->
<cfset myXmlDoc = xmlParse("C:\ColdFusion8\wwwroot\website\order.xml")>
<!--- get the path and use it to write the XML file --->
<cfset thisPath = ExpandPath("*.*")>
<cfset thisDirectory = GetDirectoryFromPath(thisPath)>
<!--- this path has to match the path of the web server --->
<!--- makes a copy of order.xml at #thisDirectory#mm_doc.xml --->
<cffile action="write" file="#thisDirectory#mm_doc.xml"
output="#toString(myXMLDoc)#">
<!--- display mm_doc.xml --->
<cfheader name="Content-Disposition" value="inline; filename=mm_doc.xml">
<cfcontent file="#thisDirectory#mm_doc.xml" type="text/xml">
CFMXPrGrmR - 14 Sep 2007 18:56 GMT
Knowing as little as I do about Unix I thought you still needed a drive
"letter" to write the XML file to. I've been told I can get to the root but
that it's root is "/bottomFolderName" (I was expecting
R:\webRootPath\yourFolder\etc\XMLFileWrittenHere).
I will post the error I saw next week, it's low on the priority right now. I
do know the code works great on Windows but failed on actual Unix web server.
I'm using CF 7.02 if it matters.
pheppler - 14 Sep 2007 21:16 GMT
On Unix/Linux you don't have driveletters and absolute paths look like relative
paths 'cause Unix/linux doesn't use \.
C:\folder\subfolder is on Unix/Linux /folder/subfolder. And very important
"Foldername" is not "folderName" and Linux doesn't support spaces in
Foldernames like Windows does. Hope this helps a bit.
BKBK - 15 Sep 2007 09:37 GMT
[i]Knowing as little as I do about Unix I thought you still needed a drive
"letter" to write the XML file to. I've been told I can get to the root but
that it's root is "/bottomFolderName" (I was expecting
R:\webRootPath\yourFolder\etc\XMLFileWrittenHere).[/i]
No, that is Windows thinking. You were told right. In Linux, a path usually
begins with the forward slash /.
I had doubts about your code itself. Did you run your version my example on
Windows? If it works, then you will only have to replace the Windows path with
something like the following. The rest of the code remains the same.
<!--- the xml file on a typical single-server installation on Linux --->
<cfset myXmlDoc = xmlParse("/opt/coldfusion8/wwwroot/website/order.xml")>
<!--- the xml file on a typical multiserver installation on Linux --->
<cfset myXmlDoc =
xmlParse("/opt/jrun4/servers/coldfusion8/cfusion-ear/cfusion-war/website/order.x
ml")>