I am trying to implement server.execute() via an include from a virtual functions library (<!-- #include virtual="lib/functions.asp"-->) that I can call on from any subfolder in the system. I am trying to implement a new function that should exist on all pages in our system, and it would be virtually unfeasible to go in and add it manually to every single page. And I need it to be implemented in such a way that it does not interfere with the code on any page which is why I am doing it as a server.execute() in a virtual lib that I know already exists everywhere in the system.
For example:
'location of routine.asp = https://example.com/admin/routine/routine.asp
Server.Execute("routine/routine.asp")
'Will work if I add the virtual lib from an ASP-page in the admin subfolder, but not if I call it from another subfolder
Server.Execute("https://example.com/admin/routine/routine.asp")
'Does not work, because server.execute can't handle that kind of fixed path
The documentation clearly states that colons and double-slashes are not allowed, but I can't figure out how I can make sure the execution of the file happens no matter where in the system it's called from.
Question: How can I make server.execute(path)'s path handle a fixed path, or change the path dynamically to make sure I can always target the file correctly?
If you want to use an absolute path make sure you are using an absolute path (full path from the root).
Think you simply need to specify the absolute path explicitly;
Server.Execute("/admin/routine/routine.asp")
Related
I need to figure out if a given (UNC) path actually points/ends/is the given path (directory).
Example: "\?\UNC\machine1\shared1". GetFinalPathNameByHandle will result in "\?\UNC\machine1\shared1".
However, if there's a symlink "sym" inside shared1 and the given path is "\?\UNC\machine1\shared1\sym", having "sym" be created with mklink and pointing to "\machine2\shared2", the result given by GetFinalPathNameByHandle is "\?\UNC\machine2\shared2".
Now, we have a QNAP NAS, with "home" folders enabled - meaning that each domain user, when navigating to "\nas\home", will end up in its own directory.
GetFinalPathNameByHandle for "\?\UNC\nas\home" results in "\?\UNC\nas\home", while I would need to get my hands on the actual directory name, like "\?\UNC\nas\homes\user_name". I do not need to read/write - I just need to know that "\?\UNC\nas\home" is really not "\?\UNC\nas\home".
This idea then propagates to any similar scenarios when "\machine\folder" ends up somewhere else (per user). Say I do not even need to know where does it really end, just that there's some kind of reparsing happening...
Any ideas?
I need to reference patients.json from patients.go, here's the folder structure:
If I do:
filepath.Abs("../../conf/patients.json")
it works for go test ./... but fails for revel run
If I do:
filepath.Abs("conf/patients.json")
the exact opposite happens (revel is fine but tests fail).
Is there a way to correctly reference the file so that it works both for tests and normal program run?
Relative paths are always interpreted / resolved to a base path: the current or working directory - therefore it will always have its limitations.
If you can live with always taking care of the proper working directory, you may keep using relative paths.
What I would suggest is to not rely on the working directory, but an explicitly specified base path. This may have a default value hard-coded in your application (which may be the working directory as well), and you should provide several ways to override its value.
Recommended ways to override the base path to which your "relative" paths are resolved against:
Command line flag (see flag package)
Environment variable (see os.Getenv())
(Fix named) Config file in user's home directory (see os/user/User and os/user/Current())
Once you have the base path, you can get the full path by joining the base path and the relative path. You may use path.Join() or filepath.Join(), e.g.:
// Get base path, from any or from the combination of the above mentioned solutions
base := "/var/myapp"
// Relative path, resource to read/write from:
relf := "conf/patients.json"
// Full path that identifies the resource:
full := filepath.Join(base, relf) // full will be "/var/myapp/conf/patients.json"
I've never used Revel myself but the following looks helpful to me:
http://revel.github.io/docs/godoc/revel.html
revel.BasePath
revel.AppPath
This is not the problem with path, but the problem with your design.
You should design your code more careful.
As far as I can tell, you share same path in your test file and reveal run. I guess that maybe you hard code your json path in your model package which is not suggested.
Better way is
model package get json path from global config, or init model with json path like model := NewModel(config_path). so reveal run can init model with any json you want.
hard code "../../conf/patients.json" in your xxxx_testing.go
I Cannot find how to use relative paths in mathematica. My directory structure is simple.
Import["G:\\Research\\Acc and Vel Runs\\5-24\\Mathematica\\Data\\250 \
Acc.xls"][[1]] // TableForm
That Demonstrates the Absolute path by using the insert path from the menus. I want this notebook to be portable. I want to give someone the "Mathematica" directory and I want them to be able to run the code. I don't want the paths to break because It will be run on a different machine. Basically I just want to use a relative path starting at the Mathematica level shown above.
In Mathematica you can get the current directory using Directory[] and you can set it to something else using SetDirectory[]. You can go back to the last location using ReserDirectory[] or check all previous locations using DirectoryStack[].
This is described in the documentation here.
You can set the current directory to the directory where the notebook is using
SetDirectory[NotebookDirectory[]]
For NotebookDirectory to work, you must be using the Front End and the notebook must be saved.
You can always use path relative to the current directory (Directory[]), for example Import["data/somedata.txt"].
Regarding directory separators: / will always works, on all of Windows/Linux/Mac. When you are typing a relative path name, it's much more convenient to just use / for portability than FileNameJoin.
I usually do this.
SetDirectory[
FileNameJoin[{$InitialDirectory, "dir1", "dir2"}]];
Quiet[Close["Log.txt"]];
logStream = Quiet[OpenWrite["xmlAreaTagsLog.txt"]];
xmlDoc = Import["XmlData.xml"];
Using $InitialDirectory gets you the .nb directory and using FileNameJoin allows you to have relative access.
When I run phpinfo() and look by the Configuration category under PHP Core, I see a directive titled include_path, with a local value and a master value.
In this case, my local value is set to
.:
./include:
../include:
/usr/share/php:
/usr/share/php/smarty:
/usr/share/pear
and my master value is set to
.:
/usr/share/php:
/usr/share/pear:
/usr/share/php/pear:
/usr/share/php/smarty
The reason I am trying to learn how this works is because there is a file in the system I am working on titled Smarty.class.php, which I'm sure sounds very familiar to anyone who uses Smarty Templating Engine.
One of the PHP files has the following includes:
require_once("Smarty.class.php");
require_once("user_info_class.inc");
The file user_info_class.inc is in the same directory as the file making the include, which makes perfect sense to me, and is the way that I've always referenced files. I decided that I wanted to open up the Smarty.class.php file and had assumed it would be in the same directory, but it was not.
After doing a bit of digging, I discovered those php_ini variables, and was finally able to locate the file in the directory usr/share/php/smarty/.
So it would seem that when making an include, it follows some sort of order between the Local and Master values for the include_path.
Assuming that my deductions were correct thus far, can someone explain the order in which PHP searches for the files to be included?
The global value is basically what's set in php.ini. The local value is what's currently being used. The local value completely overwrites the master value.
According to the manual, PHP checks the paths in the order that they are specified in the include_path setting: http://php.net/manual/en/ini.core.php#ini.include-path
In my Rails application, I need to create a symlink between two files inside RAILS_ROOT. The names of target and symlink are given as absolute paths. However, I want to create a symlink that uses relative paths, so the application folder could easily be moved.
In other words, from RAILS_ROOT/path/foo/bar and RAILS_ROOT/path/baz I want to get ../../baz as an answer.
Is there a library function (or a simple one-liner) to do that?
Try the relative_path_from method of a Pathname.