Confused about how to exec a script from console
by Justin Tolchin · in Torque Game Engine · 01/10/2005 (11:36 am) · 9 replies
Hi all,
Still getting familiar with the engine and I'm confused about how the console finds scripts to execute. It doesn't seem to matter where I put my "test.cs" file, every time I call exec("test.cs"); or exec("/test.cs"); from the console, I get a "Missing file" error. Can someone explain to me how this works? I'm just launching the standard FPS kit ("starter.fps"). Are certain directories "off-limits" for the console or something?
I've tried putting my file in the following directories:
/SDK/example
/SDK/example/starter.fps
/SDK/example/starter.fps/data
/SDK/example/starter.fps/server
/SDK/example/starter.fps/client
/SDK/example/starter.fps/client/scripts
Thanks!
Still getting familiar with the engine and I'm confused about how the console finds scripts to execute. It doesn't seem to matter where I put my "test.cs" file, every time I call exec("test.cs"); or exec("
I've tried putting my file in the following directories:
/SDK/example
/SDK/example/starter.fps
/SDK/example/starter.fps/data
/SDK/example/starter.fps/server
/SDK/example/starter.fps/client
/SDK/example/starter.fps/client/scripts
Thanks!
#2
Thanks very much for the reply but unfortunately it didn't really answer my question. I remember reading somewhere that "." is the folder the script is running in, but my problem is that when you're typing commands into the console there is no currently executing script. So what is the root path as far as the *console* is concerned? If I type the above command:
exec("./server/prefs.cs");
into the console, it says "Missing file:", even though there is a prefs.cs in the /example/starter.fps/server directory. So what would I type into the console to get that script to execute? I tried using "./starter.fps/server/prefs.cs" and using ".." instead of ".", etc. but I always get the "Missing file:" error.
If it helps any, this is the command I'm using to launch the engine:
C:\Torque\SDK\example\torqueDemo.exe -game starter.fps
Thanks!
01/10/2005 (1:52 pm)
Anthony,Thanks very much for the reply but unfortunately it didn't really answer my question. I remember reading somewhere that "." is the folder the script is running in, but my problem is that when you're typing commands into the console there is no currently executing script. So what is the root path as far as the *console* is concerned? If I type the above command:
exec("./server/prefs.cs");
into the console, it says "Missing file:
If it helps any, this is the command I'm using to launch the engine:
C:\Torque\SDK\example\torqueDemo.exe -game starter.fps
Thanks!
#3
01/10/2005 (1:56 pm)
Try exec("starter.fps/server/prefs.cs");or to be more specific, but making it an absolute path to Your particular machineexec("../Torque/SDK/example/starter.fps/server/prefs.cs");
#4
I tried:
exec("starter.fps/server/prefs.cs");
and that works fine. THANKS! I thought I'd tried that before but I guess I missed the magical combination of keystrokes. :-)
But I'm still a little confused. If you have a moment, can you explain the difference to me between these 3 commands:
exec("starter.fps/server/prefs.cs");
exec("/starter.fps/server/prefs.cs");
exec("./starter.fps/server/prefs.cs");
I would have thought they all meant the same thing, but I guess if you leave off the "." or "./" it prepends the "base" directory (/SDK/example/ in this case)? If that's true, shouldn't that be the equivalent of typing:
exec("~/starter.fps/server/prefs.cs");
because that doesn't work.
And if you put in either "." or "./" do you get the directory that the console thinks is the "current" directory (and I still don't know what that is)? Are the second and third commands functionally identical?
Thanks!
01/10/2005 (4:07 pm)
Hi Anthony,I tried:
exec("starter.fps/server/prefs.cs");
and that works fine. THANKS! I thought I'd tried that before but I guess I missed the magical combination of keystrokes. :-)
But I'm still a little confused. If you have a moment, can you explain the difference to me between these 3 commands:
exec("starter.fps/server/prefs.cs");
exec("/starter.fps/server/prefs.cs");
exec("./starter.fps/server/prefs.cs");
I would have thought they all meant the same thing, but I guess if you leave off the "." or "./" it prepends the "base" directory (/SDK/example/ in this case)? If that's true, shouldn't that be the equivalent of typing:
exec("~/starter.fps/server/prefs.cs");
because that doesn't work.
And if you put in either "." or "./" do you get the directory that the console thinks is the "current" directory (and I still don't know what that is)? Are the second and third commands functionally identical?
Thanks!
#5
c:/Torque/SDK/example/
You mentioned 3 different commands:
exec("starter.fps/server/prefs.cs");
exec("/starter.fps/server/prefs.cs");
exec("./starter.fps/server/prefs.cs");
In my mind, the last one is clear. Start with the current directory... find starter.fps within that... find server within that... find prefs.cs within that. What about the first two though? It is not clear. The first two tell you where to go after you get started, but they don't tell you where to start.
This syntax is used in UNIX and in MS-DOS. In MS-DOS, if you leave off the "." then it will first try looking in the current directory, then try looking under PATH directories, then give up. Under UNIX, it would check only the PATH directories (checking current directory by default is considered a security risk) before giving up. Torque, apparently, is more like UNIX in that it will ask for clarification rather than assuming you want the current directory.
./ is current directory.
../ is directory above current directory.
Under MS-DOS, more than two dots is not allowed. Not sure about UNIX on this point.
01/10/2005 (4:36 pm)
The current directory is the directory that your executable is in. In this case, that would be c:/Torque/SDK/example/
You mentioned 3 different commands:
exec("starter.fps/server/prefs.cs");
exec("/starter.fps/server/prefs.cs");
exec("./starter.fps/server/prefs.cs");
In my mind, the last one is clear. Start with the current directory... find starter.fps within that... find server within that... find prefs.cs within that. What about the first two though? It is not clear. The first two tell you where to go after you get started, but they don't tell you where to start.
This syntax is used in UNIX and in MS-DOS. In MS-DOS, if you leave off the "." then it will first try looking in the current directory, then try looking under PATH directories, then give up. Under UNIX, it would check only the PATH directories (checking current directory by default is considered a security risk) before giving up. Torque, apparently, is more like UNIX in that it will ask for clarification rather than assuming you want the current directory.
./ is current directory.
../ is directory above current directory.
Under MS-DOS, more than two dots is not allowed. Not sure about UNIX on this point.
#6
indeed the last two are essentially identical
~ is used to return to the root folder, which because you are executing in the console would cause it to get confused. Use the ~ only when trying to go up the folder tree.
I belive .. mean the go to the drive ie c:
01/10/2005 (4:36 pm)
The exe is in the example folder, so you need to specify subfolders from that location, ie a relative URL.indeed the last two are essentially identical
~ is used to return to the root folder, which because you are executing in the console would cause it to get confused. Use the ~ only when trying to go up the folder tree.
I belive .. mean the go to the drive ie c:
#7
I agree, the last one seems clear, but unfortunately it doesn't work (neither does the second one). Only the first one actually works. I don't have a problem with just starting from "starter.fps" and going forward (when typing in exec's from the console) it was just confusing. I could probably make the second or third variations work *if* I knew what the console considered the "current" directory, but I don't. It's also annoying that the "~" syntax doesn't work in the console commands, but that's life. No biggee.
Anyway, thank you guys for the help/clarification.
01/10/2005 (5:23 pm)
Quote:exec("starter.fps/server/prefs.cs");
exec("/starter.fps/server/prefs.cs");
exec("./starter.fps/server/prefs.cs");
In my mind, the last one is clear. Start with the current directory... find starter.fps within that... find server within that... find prefs.cs within that. What about the first two though? It is not clear. The first two tell you where to go after you get started, but they don't tell you where to start.
I agree, the last one seems clear, but unfortunately it doesn't work (neither does the second one). Only the first one actually works. I don't have a problem with just starting from "starter.fps" and going forward (when typing in exec's from the console) it was just confusing. I could probably make the second or third variations work *if* I knew what the console considered the "current" directory, but I don't. It's also annoying that the "~" syntax doesn't work in the console commands, but that's life. No biggee.
Anyway, thank you guys for the help/clarification.
#8
01/11/2005 (8:55 am)
The latter two forms don't work from the console, only from code executed inside files. In other words, the engine doesn't really consider the console to have a working directory. (The first form is basically an absolute reference from the engine's perspective.)
#9
01/17/2005 (11:18 pm)
Just wanted to thank all concerned for the posts- I've been beating my head against this same wall for the past 3 hours. It's the little things that get 'cha
Associate Anthony Rosenbaum
exec("./server/prefs.cs");the . or period represents the folder the file, which is executing, is in.subfolders are seperated wih / the forward slash, and the file in the specified folder also needs to be preceded with a forward slash.