execvp() function working fine in clion but not in terminal - execvp

I tried to run an program, which use container and execvp() function.
When I'm trying to run in the CLion, the program works fine, but when I'm running in my shell, it doesn't work, even when I use CLION's compile file.
it says: "no such file or directory".
Any idea? the arguments that I use looks OK in the two options.

After a long time, I understand what was the problem. I used clone() function to create child to the main process, and I used not right flags.

Related

Error when running scala script from terminal; however :load works fine inside interpreter

I am trying to learn Scala, or at least the basics for now.
I went to the scala website to download it from there. I followed the steps and download Coursier and called cs setup and then cs install scala:3.1.1 and cs install scalac:3.1.1.
I started writing simple scripts without classes, like how you'd do in the interpreter. So I opened a text file and wrote print('x') and saved it to filename.scala, then I went to terminal and tried scala filename.scala; however, that gave me the error ("Illegal start of toplevel definition"). I changed the code inside the .scala file to a simple var x : Int 4, and I get a different error ("Error: No main methods detected in script Desktop/filename.scala").
When I open the scala terminal and use the :load option, everything works fine. After looking around SO for a good half an hour, none of the mentioned answers helped. I understand that scala is looking for a full program with objects and methods like java. But from what I read, it should be able to run scripts like the one I wrote by guessing its type. What's the problem? Is this a problem with scala 3 or my terminal? or am I doing something wrong?
Thanks in advance.

rsimgetrtp doesn't work when i compile my gui to standalone exe

i have a problem with rsimgetrtp.
It should work with
rtp=rsimgetrtp('modelname','AddTunableParamInfo','on')
but it doesn't. I get an error when i compile my files to make standalone application. error says "Undefined function or method 'find_system' for input arguments of type 'char'"
Before compiling everything works fine. My GUI and exe files exchange data perfectly, but after compilinig i get error. I tried google it but found nothing.
Simulink functionality is not compilable. You'll need to create a dummy/placeholder parameter structure before you go through the compile process and store it somewhere (most likely in a mat-file), then load that into your deployed app. rather than trying to use rsimgetrtp within the deployed app.

How do you run tests from the command line?

To do this in-editor you open the automation tab, connect to the session and choose which tests to run.
How do you do it from the command line?
(NB. not compiling UnrealEngine/Engine/Build/BatchFiles/* comprehensively covers both building the application and compiling it. Specifically, given that you have code that is 100% happy to compile, how do you kick the test suite off)
--
Here's some more info, from recent testing on 4.10:
Running tests from the editor:
UE4Editor Project.uproject -ExecCmds="Automation RunTests MyTest"
Notice the absence of the -Game flag; this launches the Editor and runs the tests successfully in the editor console.
Running the game engine and using the 'popup log window':
UE4Editor Project.uproject -Game -ExecCmds="Automation RunTests MyTest" -log
This runs the game in 'play' mode, pops up an editor window; however, the logs stop at:
LogAssetRegistry: FAssetRegistry took 0.0004 seconds to start up
...and the game never closes or executes the tests.
Running the game engine and logging to a file:
UE4Editor Project.uproject -Game -ExecCmds="Automation RunTests MyTest" -log=Log.txt
This runs the game in 'play' mode, and then stops and never exists.
It does not appear to run any tests or log to any files.
The folder Saved/Logs does not exist after quitting the running game.
Running in the editor, test types, etc...
see: https://answers.unrealengine.com/questions/358821/hot-reload-does-not-re-compile-automation-tests.html,
Hot reload is not supported for tests; so this isn't an option.
There's also been some suggestion in various places that the test type (eg. ATF_Game, ATF_Editor) has some affect on if runs are or can be run; perhaps this is an issue to, but I've tried all kind of combinations with no success.
--
I've tried all kinds of combinations of things trying to get this working, with no success so it's time for a bounty.
I'll accept an answer which reliably:
Executes a specific test from the command line
Logs the output from that test to a file
Right, no one has any idea here or on the issue tracker.
After some serious digging through the UE4 source code, here's the actual deal, which I leave here for the next suffering soul who can't figure this out:
To run tests from the command line, and log the output and exit after the test run use:
UE4Editor.exe path/to/project/TestProject.uproject
-ExecCmds="Automation RunTests SourceTests"
-unattended
-nopause
-testexit="Automation Test Queue Empty"
-log=output.txt
-game
On OSX use UE4Editor.app/Contents/MacOS/UE4Editor.
Notice that the logs will, regardless of what you supply, ultimately be placed in:
WindowsNoEditor/TestProject/Saved/Logs/output.txt
or
~/Library/Logs/TestProject/output.txt
Notice that for mac this is outside of your project directory, in, for example, /Users/doug/Library/Logs/TestProject. (Who thought that was a good idea?)
(see https://wiki.unrealengine.com/Locating_Project_Logs#Game_Logs)
You can list automation tests using:
-ExecCmds="Automation List"
...and then parse the response to find tests to run; automation commands may be chained, for example:
-ExecCmds="Automation List, Automation RunAll"
Do you mean the in-editor command line or the Windows command line?
In the editor you can use the Automation command with parameters, e.g. Automation RunAll
In the Windows command line you can specify unreal command parameters with -ExecCmds. To run all tests in your project: UE4Editor.exe YOURPROJECT -Game -ExecCmds="Automation RunAll"
For anyone still wondering, there is a bug in the editor that make it so the test list is flushed before they are run when they are started from the command-line (be it at startup or after).
This means that the editor actually compiles a list of tests to run, which is then flushed by another part of the program. The editor then thinks that it has finished running all the test and, since there is no errors, shows that they all succeeded.
I can post how to do a fix to this if anyone is interested, but it introduce another minor bug.

gtk - After calling external command, how to prevent it from closing gtk main window

I want to read data from GtkListStore and build an excel by phpExcel. First, I build a php file according to the GtkListStore, then I use php and phpexcel lib to compile and build execl file.
In my gtk code (compile in MinGW environment), I use execvp(cmd[0], (const char **)cmd); to call the external command -- php. In fact, cmd[0] is php.exe and cmd[1], cmd[2] ... are the parameters for php. After calling the php command, my gtk main window is closed and it quits my gtk program.
How can I prevent the php command from quitting main program? Should I use something else instead of execvp? Thank you.
execvp() and friends replace the current process with another process, so it's no surprise that your program quits. Use g_spawn_sync() or a related function - that will run your php program, then return control to your original program.
Let me answer my own question. Followed is the summary to what I have googled and tried within the past few days. It has nothing new but maybe is useful to a newbie like me.
First, thank ptomato. To avoid my problem in GTK, it must use g_spawn_sync or related functions. If your command is absolute path, you don't have to use the flag G_SPAWN_SEARCH_PATH, otherwise, make sure to use the flag.
Following are something related in MinGW environment.
-> gspawn-win32-helper.exe
In MinGW, to use g_spawn_sync, it must have gspawn-win32-helper.exe installed. When I installed GTK environment, I only extracted the useful lib or exe file I think it is useful then I missed gspawn-win32-helper.exe and it resulted in the problem -- Failed to execute helper program (No such file or directory) mentioned in the above comments. After extracting gspawn-win32-helper.exe from ftp://ftp.gtk.org/pub/glib/2.10/win32/glib-2.10.0.zip and installing it, g_spawn_sync worked.
-> For canonical Windows paths, both double backslashes and single forward slash work, e.g., c:/foo/bar and c:\foo\bar work.

Arguments to PyUnit not parsed correctly

When we try to run a PyUnit test in Eclipse as a Python unit-test, it fails. This is because the arguments sent to PyUnit come in the following order: file-to-test --port portno. We have discovered that there is an environment variable called POSIXLY_CORRECT that, if set, makes PyUnit expect the arguments to come in a certain order, options first.
We have looked everywhere in Eclipse to try and find where these arguments are set, but are unable to find them. So as a workaround we change the run configuration to use an environment without the POSIXLY_CORRECT set. But this is very awkward.
Does anyone know how to solve this so that we do not need to modify the run configurations to be able to run our tests?