trying to run an .exe file in lua - lua

recently i have been trying to run a script in lua that through os.execute() will execute a script in C# compiled into an executablethat is in the same directory as my script.
In my first attempt adding the entire directory until the executable worked:
os.execute("C:\\ServerTest\\test\\tex\\testcode.exe")
however I need this script to work on other computers, which means I can't add the entirely path to the file.I tried countless methods to execute the .exe file inside the same directory without using the entire path and none of the methods worked
os.execute("./testcode")
os.execute [[".\testcode.exe"]]
os.execute(".\\testcode.exe")
os.execute "testcode.exe"
I even tried to create an environment variable and run the entire directory from it xD
os.execute("set wTest=%cd%")
os.execute("%wTest%\\testcode.exe")
but nothing worked. I also tried to use io.popen() but didn't get results either (because the executable will close a computer process, it does not give any output :V)
does anyone know how I can do this?????

Related

PyCharm: Unit testing directory setup with remote interpreter

For years I've been running a Docker container on my local machine and using it as a remote Python interpreter via SSH in PyCharm. This works great (though 2022.2.1 brought a lot of new bugs that have been slowly being ironed out) for running my code! I'm now on 2022.2.3.
However, I'm having issues running unit tests. In the past (i.e. before version 2022.2.1), I could simply right click my tests directory (a direct child of my main project directory) and click Run Python tests in test... and it would all work as expected.
Now, though, when I click this, I receive an error message about "No such file or directory."
I've tried everything I can think of- I've setup my path mappings in the Python test run config to exactly match those shown in my Python run config, and have tried every version of directory and subdirectory in the mappings and working directory, but I always receive an error about either having an empty test suite (no tests found), or that the directory "must be in the project."
It seems like no matter what I do, PyCharm is trying to create a temp directory somewhere, or is trying to read from some temp directory that I never specified, because I see errors this like:
AssertionError: /tmp/pycharm_project_405/docker/tests: No such file or directory
Yet I never created, specified, or requested a temp directory of any sort, let alone one named /tmp/pycharm_project_405/; this is a mystery to me.
PyCharm with an SSH interpreter is rapidly becoming unusable for me and my team because we cannot figure out how to set this up. Can anybody please offer some guidance on what we need to do?
Thank you all so very much!
I tried:
Changing run config for Python tests to match the working directory and path mapping of Python run configs (which work)
Directly specifying the path to the tests from the container's perspective
Setting up run config templates
Specifying one directory up/down from the actual tests
Expected:
Unit tests to be found and run as they were in previous versions of PyCharm
Answer
Create a run config for testing
In the testing run config, set Target: to Custom
Set the correct remote interpreter
Set Working directory to the test folder
Set TWO path mappings: 1) Map the code directory (in my case, the parent directory of the tests folder) and 2) Map the test directory itself
Voila!!!

Using TDBLoader in JENA

I'm trying to learn how to use TDBLoader using this example I found:
https://github.com/ijdickinson/jena-tdb-ont-example
However, when trying to run the init-demo script, I keep running into issues
https://github.com/ijdickinson/jena-tdb-ont-example/blob/master/src/main/script/init-demo
I'm using cygwin to attempt to run the script, but I keep getting please ensure $Path contains $TDBROOT/bin
I set TDBROOT= C:\Development\apache-jena-2.12.1
And my Path has "%TDBROOT\bin"
I'm really new to using command line and shell scripts, so I'm not at all familiar with how to go about debugging this.
I have my tdbloader in apache-jena-2.12.1\bin , is there a way I can check if this is even working? Or if my path is properly set?
I tried "tdbloader" and "-v tdbloader" in command line and I get "tdbloader" is not recognized...
That's not supposed to happen if my path is set correctly, right?

Notepad++ sets incorrect path when running script

I have a simple script that I want to import into another with require, but when I run it from Notepad++ I get the usual error that require produces.
The funny thing is that it worked an hour ago and I did not restart the computer since then.
The files are in the same directory, so the simple file name (without .lua) worked and should still work. (relative path)
Lua runs the script just fine.
this is what I entered in Notepad:
cmd /k lua "$(FULL_CURRENT_PATH)"
Earlier I also had a problem with Penlight, maybe there is some connection, so here it is:
I tried to require"pl" but it failed to find the module. (ran from SciTE, worked prevously)
I tried it in the Lua command line and it worked like a charm.
Tried again in SciTE and voila it worked again.
I have no idea what causes any of them.
ps.: using the lfs module and os.execute("cd /d ...path...") did not work
Lua is searching for your required module in the folders of LUA_PATH. In the script you run via F5, put this statement:
print('current path is:')
os.execute('cd')
require 'someModuleThatDoesntExist'
After printing the "working" forlder (Program Files/Notepad++), it tries to find the required module and fails. The traceback shows that Lua looks through many different folders, none of them being the one containing FULL_CURRENT_PATH, so it can't find the module.
You have several choices:
put your scripts in one of the listed paths
set LUA_PATH in your environment to contain the folder name where your scripts are located
change package.path from your script so it knows where to look for other modules. You could do this by either:
including an extra parameter to your F5, namely CURRENT_DIRECTORY, and make your script take its first command line param (CURRENT_DIRECTORY) to add it to package.path
parse arg[0] when your script starts, to get the folder containing script, and extend package.path
For example with #3, first option, you would use
cmd /k lua "$(FULL_CURRENT_PATH)" "$(CURRENT_DIRECTORY)"
in notepad++ and in your Lua module you would use
thisModuleDir = arg[1]
package.path = thisModuleDir .. ";" .. package.path
require 'yourmodule'

ACE TAO cannot get NameService object in debug mode

I'm running a multi-program projects using ACE TAO. I set the Environment Variables and compiled ACE_TAO environment. Then I copied the tao_cosnaming.exe to my project run directory and use a .bat to start the naming service.
The programs run well if I start them directly, but they could not get the "NameService" correctly when I invoke obj = orb->resolve_initial_references("NameService") in debug mode. (I could not run obj->_non_existent(), it throws an error).
It seemed because the Naming Service is implemented as a remote one. When I invoke obj = orb->invoke resolve_initial_references("RootPOA"), things are fine, because RootPOA is local object so obj->_non_existent() return immediately.
The .bat file is like:
cd /D %DTAX_RUN_DIR%
tao_cosnaming -ORBEndPoint iiop://%DTAX_NAME_SERVICE_HOST%
The DTAX_RUN_DIR and DTAX_NAME_SERVICE_HOST are Environment Variables. DTAX_RUN_DIR is project run directory and DTAX_NAME_SERVICE_HOST=169.254.51.81:10493
Could anybody share some ideas on what is going wrong? Thanks!
It's hard to give a definite solution with just the information you provided, but in my projects I need to pass "-c" (without the quotes) as a command argument so that I can debug it, maybe you need to do the same.
In Visual Studio in the project properties you can find the Command arguments field in Properties/Debugging.

Paths in Lua: Unable to run script in Windows for Lua that requires 'wx'

I am using Lua for Windows.
I am trying a sample script from the wxLua website; however, when I run the script, it fails on the first line, which is require 'wx' with:
lua: cannot open wx: No such file or directory
However, when executing require 'wx' in the REPL/interpreter, it works OK.
I have done another script to output print(package.cpath) and print(package.path), and they seem the same to me as in the REPL.
Why, when running the script, is it not able to find 'wx'?
In this instance, I am running both the script and the shell/REPL from the same folder.
The value of package.cpath (produced by test script and Lua shell):
.\?.dll;.\?51.dll;C:\Program Files (x86)\Lua\5.1\?.dll;C:\Program Files (x86)\Lu a\5.1\?51.dll;C:\Program Files (x86)\Lua\5.1\clibs\?.dll;C:\Program Files (x86)\ Lua\5.1\clibs\?51.dll;C:\Program Files (x86)\Lua\5.1\loadall.dll;C:\Program File s (x86)\Lua\5.1\clibs\loadall.dll
and package.path (again, the same from the script and Lua shell):
;.\?.lua;C:\Program Files (x86)\Lua\5.1\lua\?.lua;C:\Program Files (x86)\Lua\5.1\lua\?\init.lua;C:\Program Files (x86)\Lua\5.1\?.lua;C:\Program Files (x86)\Lua\5.1\?\init.lua;C:\Program Files (x86)\Lua\5.1\lua\?.luac
There is a wx.dll in C:\Program Files (x86)\Lua\5.1\clibs which is referenced by the cpath value above.
OK, this was my own stupidity: I named the file wx.lua, so obviously require was trying to pick up the script itself.
By simply renaming the file, it works fine.

Resources