Linux scripting: Unable to create directory on linux platform


Symptom

I cannot find any information in the documentation or Microsoft vbscript documentation to create a directory without using ActiveX. A workaround would be to do a system call, but I also cannot find a way to achieve this. As a last resort, I thought of creating a Browser and directory using the XSIUIToolkit.FileBrowser. But, I cannot find a method to create this type of directory. The way with ActiveX is like this:

 ' Build the new directory where to place those images
 'Set oFS = CreateObject("Scripting.FileSystemObject")
 'Set oFolder = oFS.CreateFolder(sBakedPicturesPath)


Cause

There does not exist a Scripting.FileSystemObject on non-Windows platforms. Therefore, you cannot create, destroy, or manipulate files directly with VBscript.

Solution

You can, however, use the System () command (listed in the XSI commands reference, and not the object model) to pass a string to the OS to do your file-actions. The called command could be an OS command such as cp, mv, mkdir, or it can be a script you have written in another language such as Perl, JavaScript, or one of the UNIX shell languages (awk, C, bourne, Korn, etc).

Example

 dim Directory, status
 Directory = "/usr/tmp/mystuff"
 status = System( "mkdir " & Directory )
 if ( status <> 0 ) then
 ' non-zero return value
 ' possible error depending on the command
 LogMessage "Doh! Possible error executing: " & "mkdir " & Directory,
 siError
 end if

The other main workaround is to get a 3rd party development/scripting environment that has it's own File I|O libraries, such as ScriptEase from Nombas (http://www.nombas.c) which is based on Javascript/Jscript. Or finally, as a last resort, you can create your own ActiveX control to handle File I|O.




Posted: 2/8/2002

This page was last modified 21:01, 2 Nov 2010.
This page has been accessed 11379 times.

© Copyright 2009 Autodesk Inc. All Rights Reserved. Privacy Policy | Legal Notices and Trademarks | Report Piracy