Pathing issue with UOX3.exe console web interface

Want to discuss changes to the UOX3 source code? Got a code-snippet you'd like to post? Anything related to coding/programming goes here!
Post Reply
Maxx
UOX3 Newbie
Posts: 18
Joined: Thu Feb 09, 2006 9:56 pm
Has thanked: 0
Been thanked: 0

Pathing issue with UOX3.exe console web interface

Post by Maxx »

Greetings,

I have been working on a web based interface for the UOX3 console.
The problem that I am having occurs when the VBScript that I am using
calls the UOX3.exe. I am logging the output to a file and error message that I get when I starting the console is:

"ERROR: Data directory C:/Documents and Settings/Administrator/Desktop/muldata/ does not exist"

I had posted on the General boards about this issue, however I thought that I should bring it here because I tracked down the issue and it could be a systemic issue for other folks as well.

Here is the issue:
In the UOX3.ini my directories paths are as follows:

Code: Select all

[directories]
{
DIRECTORY=./
DATADIRECTORY=G:/UOX3/datafiles/
DEFSDIRECTORY=./dfndata/
BOOKSDIRECTORY=./books/
ACTSDIRECTORY=./accounts/
SCRIPTSDIRECTORY=./js/
BACKUPDIRECTORY=./archives/
MSGBOARDDIRECTORY=./msgboards/
SHAREDDIRECTORY=./shared/
ACCESSDIRECTORY=./accounts/
HTMLDIRECTORY=./html/
LOGSDIRECTORY=./logs/
DICTIONARYDIRECTORY=./dictionaries/
} 

cServerData.cpp uses GetCurrentDirectory() to assign the DIRECTORY= path value.

All of the other directory's are assigned there values by parsing the UOX.ini file.

The value that is returned by GetCurrentDirectory() is the location where UOX3.exe is running Because that value is used (in my case "C:/Documents and Settings/Administrator/Desktop/") all of the data directories paths are incorrect. Because the path of execution is not the file path, the error occurs.

As I see it, the way this is currently iimplemented, there is nothing that can be done to correct this behavior other then a source change. The fix is simple, but it's outside of my current scope to address. What do you all thing?

Great group of folks here, thanks for making me feel welcome!

Maxx
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

I checked up on this in the source, and the problem actually isn't UOX3's handling.

UOX3 first tries to move to the specified directory, if it cannot do so, it moves to the current working directory. In your case where the files are (I'm guessing) not immediately in the current working directory, you need to manually specify the file paths in the uox.ini

So make all of your entries read something like this

C:\uox\muldata\

Of course that being whatever folder you actually have it in, rather than using the ./ (which is only meant to move within the current working directory)
Scott
Maxx
UOX3 Newbie
Posts: 18
Joined: Thu Feb 09, 2006 9:56 pm
Has thanked: 0
Been thanked: 0

Post by Maxx »

I re-read your replay and thought of another question, how is the current working directory determined? If the working directory is valid, then it appears that it is assigned as the Root value, and that is where the problem appears to occur. The current working directory value I believe is going be be valid. If you can point me in the right direction I would love to take a look at that code segment. :)


Thanks giwo. I did that an no luck. I took a look at the code that I think is the cause of the behavior. Please do forgive me if I am wrong here, and do enlightment me where I am missing the problem.

Code: Select all

	UString wDir( curWorkingDir );
	wDir = wDir.fixDirectory();
	UString tDir;
	Directory( CSDDP_ROOT, wDir );
	tDir = wDir + "muldata/";
This is how I read this:

Code: Select all

	UString wDir( curWorkingDir );
           - Get the current directory that UOX3 is running in.

	wDir = wDir.fixDirectory();
            - Remove spaces and \s'       

            UString tDir; 
            Directory( CSDDP_ROOT, wDir );
- Assign the directory path to be the cuurent path that UOX3 is running in. In my case "C:/Documents and Settings/Administrator/Desktop/"
 
	
            tDir = wDir + "muldata/";
tDir is now "C:/Documents and Settings/Administrator/Desktop/muldata/"

Changing the value of DIRECTORY=./   has no effect bacause the value is assigned by the curWorkingDir call.
Being a newbie, I am certain that I am missing something, I just need to figure out what part.
Last edited by Maxx on Wed Feb 22, 2006 12:00 am, edited 1 time in total.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Ahh but you are looking at ResetDefaults(). That code is called before it loads in the uox.ini. It changes those values when the ini is loaded.
Scott
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

I have another idea....


Try moving your uox.ini into that Directory... C:/Documents and Settings/Administrator/Desktop/ as that is what it will be seeing as current working directory, that is where it will be trying to pull the ini from.
Scott
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

Maxx wrote:Being a newbie, I am certain that I am missing something, I just need to figure out what part.
You need to set ALL paths to the correct place, like this:

Code: Select all


[directories]
{
DIRECTORY=G:/UOX3/
DATADIRECTORY=G:/UOX3/datafiles/
DEFSDIRECTORY=G:/UOX3/dfndata/
BOOKSDIRECTORY=G:/UOX3/books/
ACTSDIRECTORY=G:/UOX3/accounts/
SCRIPTSDIRECTORY=G:/UOX3/js/
BACKUPDIRECTORY=G:/UOX3/archives/
MSGBOARDDIRECTORY=G:/UOX3/msgboards/
SHAREDDIRECTORY=G:/UOX3/shared/
ACCESSDIRECTORY=G:/UOX3/accounts/
HTMLDIRECTORY=G:/UOX3/html/
LOGSDIRECTORY=G:/UOX3/logs/
DICTIONARYDIRECTORY=G:/UOX3/dictionaries/
} 
Maxx
UOX3 Newbie
Posts: 18
Joined: Thu Feb 09, 2006 9:56 pm
Has thanked: 0
Been thanked: 0

Post by Maxx »

Update:

Hahaha we where all posting at the same time, you guys are the bomb!
Excellent. Giwo you where right on the money.
_
Giwo - Thank you for the explination! I found the problem!

Because the Default setting look for the UOX.ini in the path of execution.
Which is not where the UOX.ini file is, it does not find it and continues to exectute. It errors out as soon as it trys to load the UOX.ini and does not give an error that the UOX.ini was not found (as is the case) but it errors on the Data directory.

The root cause is that the default path to the UOX.ini is incorrect. I copied the UOX.ini to the path that GetCurrentDirectory returned and it loaded with no errors.

So the fix would appear to be to have the default path assigned to a system variable that could be read in as an optional default.

What do you think?

Maxx
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Well, unfortunately we cannot read system variables, as it is a cross-platform program. There should be some way for you to set the current working directory of the program on your side, though.

[EDIT]

As a side note, I noticed the same basic problem as you did, with it not letting us know it was using default values, so I have corrected that for the next release.
Scott
Maxx
UOX3 Newbie
Posts: 18
Joined: Thu Feb 09, 2006 9:56 pm
Has thanked: 0
Been thanked: 0

Post by Maxx »

giwo - Thanks again for your help on this. Rather then using a system variable, if there was a way to modifiy the default value that would work as well.

I do not know of a way to change the path of execution but I will look into that. Thanks again.

Maxx
punt
VIP
Posts: 244
Joined: Wed Mar 24, 2004 7:46 pm
Has thanked: 0
Been thanked: 9 times

Post by punt »

giwo wrote:Well, unfortunately we cannot read system variables, as it is a cross-platform program. There should be some way for you to set the current working directory of the program on your side, though.

[EDIT]

As a side note, I noticed the same basic problem as you did, with it not letting us know it was using default values, so I have corrected that for the next release.
Actually, you can. System variables are supported on all "supported" platforms. And actualy the code isn't that different .

The following is standard C library:

Code: Select all

     #include <stdlib.h>

     char *getenv(const char *name);
So one could look for a variable, and then if not present, use the default or the location the exe is run from.
Maxx
UOX3 Newbie
Posts: 18
Joined: Thu Feb 09, 2006 9:56 pm
Has thanked: 0
Been thanked: 0

Post by Maxx »

Punt - Right on! That rocks.

From the looks of it, this would not be that difficult to implement. Allowing for scripting functionallity outside of the core code set would be a huge boost for folks like me that want to develope applications that would function independantly.

Exporting a system variable would allow for every platfom that can run UOX3 to use a native scripting language, that is some nice bang for the buck for just a few lines of code.

Is this something I should put in an enhancement request for?
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

I don't imagine it's very hard to implement, especially given the function pointed to be Punt. But I would question why you are executing it out of it's proper working directory anyway.

One alternative you can consider. Rather than calling the binary directly, you can call a shortcut to it, in which the shortcut is set to start in the proper directory.
Maxx
UOX3 Newbie
Posts: 18
Joined: Thu Feb 09, 2006 9:56 pm
Has thanked: 0
Been thanked: 0

Post by Maxx »

Maarc - I am keeping all files in their default directories. The problem occurs because the web interface uses a JAVAScript wrapper that calls an ActiveX componate which in turn executes the VBScript.

If there was a way to force the path of execution to be the path where the files are located then I would be set. I am going to look into that.

Here is the layout of how I have things setup.

G:\UOX3
G:\UOX3\datafiles
G:\UOX3\Web

Every other directory is default.

Within the Web directory there I have created a web interface that provides a unified panel with tabs to access log files and display console
output.

The default web page updates at regular intervals refreshing the console and log file display windows. One window it a contral panel interface that
it is setup to do all the command that can be executed in the control panel.
It all stops and starts UOX3.exe

Here is the code that I am using to to call the VBScript that starts UOX3.exe. This is in an HTML page.

Code: Select all

function AutoStart() {
 var myshell = new ActiveXObject( "WScript.shell" );
 myshell.run( '"G:/UOX3/Auto_Start_UOX3.vbs"', 1, true );
}
The Auto_Start_UOX3.vbs then creates a shell that UOX3 runs in.
The code that does that is:

Code: Select all

conQ = chr(34)
strUXO3path = "G:\UOX3\"
strUXO3Exe = "UOX3.exe"

set objShell = CreateObject("WScript.Shell")
scriptPath = conQ & strUXO3path & strUXO3Exe & conQ
exeFile = scriptPath & "> "
txtFile = strUXO3path & "\logs\UOX3Con.log"
Cmd = "%comspec% /k" & exeFile & txtFile
objShell.Run Cmd, 1, True

Set objShell = nothing
The file that executes this code is located in the same directory as UOX3.exe. You would think that the path would be the same, but it is not because the WScript.Shell object executes under a diffrent path.

I am going to look into how to set the path as giwo suggested and I will also try calling a shortcut as you recommend Maarc.

Thanks for all of the idea! Great group of folks here.

Maxx
Maxx
UOX3 Newbie
Posts: 18
Joined: Thu Feb 09, 2006 9:56 pm
Has thanked: 0
Been thanked: 0

Post by Maxx »

The way that WScript.Shell handles paths is the problem. I changed my code to address the pathing problem.

In a nutshell, the WScript.Shell function does not change the path properly. I had to use a work around, but I can not get everything working. For those of you that are interested, I changed the code to this:

Code: Select all

scriptPath = conQ & strUXO3path & strUXO3Exe & conQ
txtFile = "> " & strUXO3path & "\logs\UOX3Con.log"
objShell.Run "cmd.exe" 
wsh.sleep 1000 ' wait 1 second 
objShell.AppActivate "C:\WINNT\system32\cmd.exe"
'wsh.sleep 1000 ' wait 1 second 
objShell.SendKeys "% G:{ENTER}" 
objShell.SendKeys "% CD UOX3 {ENTER} UOX3.exe " & txtFile & "{ENTER}"
Set objShell = nothing
If you try to change the path by using Cmd = "%comspec% /k CD G:\." it will fail. Although going to C:\. would work. This appears to be a functionallity limitation with that function. My work around is to use send keys and just "walk through" it.

A big thanks for all of the help!

Maxx
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Setting the working directory - http://www.microsoft.com/technet/script ... _cyst.mspx

Looks like this might solve your problem too.
Seth
UOX3 Newbie
Posts: 2
Joined: Thu Apr 23, 2009 9:38 pm
Has thanked: 0
Been thanked: 0

Post by Seth »

Hi all, "new" to the board :)



Just wanted to update this thread, since I came her for my problem, and it was somewhat simulair..

First off, running the Windows Client, not linux. Default set up, from the guide. Got this error:

ERROR: Data directory C:/Documents and Settings/Administrator/muldata/ does not exist

The guide states that launching from the command line was a good idea, the problem is that if you don`t launch from withing the UOX folder, it won`t find the "relative" paths. IOW, don`t past the direct path to UOX.exe into cmd. (btw, setting full paths in the ini didn't work either, so this seems like a crucial step..).

Soloution (for me anyway). Manually navigate into the UOX folder, launch UOX.exe



CommandLine input: (working directory> prompt)
The WRONG way:
C:\Documents and Settings\Administrator>"E:\Program Files\uox\uox3.exe"
(Produces my initial error)

The RIGHT way:
E:\Program Files\uox>"uox3"


A simple mistake, but hard to spot and/or anticipate.

Hope someone will find this usefull as well
Post Reply