How to capture the Notes Data directory specified in notes.ini? - lotus-notes

I need to get the value for the Notes data directory. I need it for a scheduled agent I am going to run. The program directory and data directory are on separate drives.
I thought the following code would work but I am not getting a return value.
String console = session.sendConsoleCommand(servername, "show config Directory");
//Code runs but the following line does not display anything
System.out.println(" Here is console value: " + console);
There are not any permission or other errors. What am I missing?
V/R,
Kev

Why use this obscure construct? Do you need the directory of ANOTHER server?
If you need it from the server where the agent runs then just use
String directory = session.getEnvironmentString("Directory", true)

Related

Finding and saving present directory of a SAS-Studio-program in a Linux server

I am trying to make a macro variable in SAS Studio which saves the "present working directory" as a macro variable.
The SAS-program is run in a "CPF" process flow file in SAS Studio, and the whole SAS-file and processes are saved and run in a Linux server.
In SAS-Studio, the location of CPF-process flow file seems like in the directory /sasdata/model_v1, and when I run a Linux command like X "pwd" then I expect that the result will give /sasdata/model_v1, but I get another directory instead like /sasinstall/sasconfig/Lev1/SASApp instead, I guess the the process flow file with CPF-suffix is run from this directory.
So the question is how I can find and save the working directory of my cpf-file and save as a macro-variable, or even maybe for my other sas-files too, I may need the solution for both SAS-files and CPF-files.
If I find the directory, then I guess it should be enough to save them as macro-variable by using %let macrovariable = "/directory"
I don't think SAS will show you the path of the process file. It doesn't in SAS/Studio 3.5.
It will set the path for a normal program file (as long as you have saved it) in the _SASPROGRAMFILE macro variable.

FS won't create file

I want to create a simple console application that would compare two files based on their filename and output the result into a new file.
My problem is that NodeJS refuses to create a new file if it doesn't exist, and acts like it doesn't exist even if I create it manually.
compare = (data) -> # data is being read from process.stdin
fname = "#{data}_compare.txt"
stdout.write "Attempting to compare #{data}" # stdout = process.stdout
fs.writeFileSync fname, 'A test.'
NodeJS returns Error: ENOENT, no such file or directory in both cases (when I want it to create the file, as well as when the file already exists).
I want the file to be created in the same folder from where the application is run, so path shouldn't be an issue at all (and indeed is correct in the error message).
I tried to specify {flags: 'w'} too, but as far as I know, that's the default value anyways, so it changed noting.
I'm running on Windows 10, tried running command prompt under administrator too, still nothing. Any idea what could be causing this?
The data variable is read from stdin and therefore contains a newline at the end. This is probably what's causing the non-descriptive ENOENT error.
You can remove the newline (and any other whitespace that user might have accidentally entered) with data = data.trim()
This would be better than the substring solution since the newline is 2 characters only on Windows and 1 character elsewhere.
Make sure the path exists (not necessarily the file itself, but the folder structure), and that the process user has write permissions.
An ENOENT error tells you that a component of the specified pathname does not exist -- no entity (file or directory) could be found by the given path.
Make sure you are putting the 'dot':
'./path/to/file'

nodejs fs(filesystem) working locally but not on server

I have my script all ready for my server except a variable is not loading on the server because it seems the file system doesn't interpret the path in the same way on the server (Ubuntu 14.04 x64 vmlinuz-3.13.0-57-generic). When I test my server locally on OS X 10.11.1 it all works fine but on the server the file cannot be found.
var jsonHourlyFile = './data/jsonHourly.json';
console.log(jsonHourlyFile);
console.log(fs.existsSync(jsonHourlyFile));
if (fs.existsSync(jsonHourlyFile)) { //Why was this in the function in the first place...?
console.log("loaded JsonHourlyFile")
var jsonHourly = jsonfile.readFileSync(jsonHourlyFile);
} else {
var jsonHourly = JSON;
console.log("jsonHourlyFile not found!")
}
This Returns true on my computer and false on the server. I've copied all the file correctly to the server using FileZilla and can confirm they are there.
I suspect it has to do with the file path. Though I thought that using ./ will always point to the right map. Who could elaborate on this?
I must comment on your last sentence :
"Though I thought that using ./ will always point to the right map."
This is not true. What ./ means, is "in this directory", i.e. where the script is executed.
On you local machine, you say your script is executed in /Users/me/WebstormProjects/WebTest, which means that your JSON file should be located in /Users/me/WebstormProjects/WebTest/data/. We know this is true since the script works on your machine.
Now, on the server, you say the script is executed in /root/WebTest/bin. So unless there is a data/ folder in that particular directory, which contains your JSON file (who's path would therefore be /root/WebTest/bin/data/jsonHourly.json), your program will not execute as expected.
There are many ways to solve this, I couldn't tell which one is the best. You just need to make sure that your local machine and the server have the correct paths to the file, which can be very different considering both Operating Systems aren't the same.
More about paths on Wikipedia.

Inno Setup - How to replace UserName with string

first attempt at posting this question was with severe jet lag. This re-edit of the question I only have the associated sleep deprivation...
I want to know the best way to use the installer to capture path information and then remove any reference to the user profile.
My program is designed to run from a central network location. To reduce network traffic some files are copied to a local drive, eg. AppData\MyProg\
I use a file browse dialogue so the person installing can specify the location:
pg_LocalPaths := CreateInputDirPage(pg_CentralPaths.id,
'Confirm File Locations For User Settings', 'To improve user experience these locations should be off the network.',
'Default Locations are:', False, 'New Folder');
// Add file browswer item (with an empty caption)
pg_LocalPaths.Add('Supporting files will be copied here by the application:');
pg_LocalPaths.Add('User settings (for a single user) will be saved here:');
// Set initial value
pg_LocalPaths.Values[0] := GetPreviousData('pg_LocalPaths0', ExpandConstant('{userappdata}\{#pFolder}'));
pg_LocalPaths.Values[1] := GetPreviousData('pg_LocalPaths1', ExpandConstant('{userappdata}\{#pFolder}'));
During install the local drive location is specified and stored in a config file.
An issue that I failed to predict is that when the program is installed, the path in the config file is defined for a single user, namely the user performing the install. In practice any user should be able to run the program...
To get the correct path for any given user, my software looks for a string "{UserName}" and replaces it with: Environ(UserName)
MyPath = Replace(MyPath, "{UserName}", Environ(UserName))
So, for example, in the installer I need to replace:
C:\Users\My Name\My Program OR C:\Users\My Admin\My Program
with something like:
C:\Users\\{UserName}\My Program
I alreay have this working in My Program but I am not sure of the best way to get it working in Inno... My inital thought was to write the config file like this:
StringChangeEx(MyPath, "My Name", "{UserName}", True)
Would like some perspective on this, not sure how to get it working for all situations.
Cheers,
You're doing it the wrong way.
Don't store the complete path in the config file; merely store a value that indicates that the user wishes to store data in the usual per-user location. (Or don't store any value, since that should be the default anyway.)
Then in your application, on every run of your application, use the Shell API to fetch the current AppData path for the current user and append your app's unique subfolder to this.
Note that it is perfectly valid for the user's AppData path to not contain their username, and not even be on C:. Don't make assumptions; use the Shell API. That's what it's for.
(Exactly which one to use and how to call it varies depending on target OS and your programming language of choice, which you haven't specified.)

SAP, how to checkIn document files?

I want to create a new document in SAP. Additional I have some files which belongs to this document, these files I want to upload to the SAP knwolegde base.
I'm using BAPI_DOCUMENT_CREATE2 to create or BAPI_DOCUMENT_CHECKIN2 to add files to a document info data. Every thing works fine, except file upload or checkin.
I'm using the DOCUMENTFILES table. I add a row for each file, currently I set only three fields:
row["STORAGECATEGORY"] = "DMS_C1_ST";
row["DOCFILE"] = "c:\temp\bom.pdf";
row["WASAPPLICATION"] = "PDF";
BAPI erro message:
"Error while checking in and storing c:/temp/bom.pdf"
I set the parameter
PF_FTP_DEST = "SAPFTPA";
PF_HTTP_DEST = "SAPHTTPA";
I have looked in the log data (slg1). I found following entry:
ERRMSG: Error in opening file "..." for reading (No such file or directrory)
V1: SCMS_DOC_CREATE_FILES
V2: 13
It would be nice if anybody has an idea and could bring some light in this issue.
Thanks in advance
Thomas
Remember that BAPIS run inside the application server and are not allowed to make any assumptions about the client side. This also means that they can't call back to the SAP GUI and upload a file from there. C:\temp\bom.pdf has to be a file on the application server, not your local machine!
Have you considered using
row["DOCFILE"] = "bom.pdf";
row["DOCPATH"] = "c:\temp\";
Let me know how it goes, or if you have already done with it then please paste your solution.

Resources