When running script: "julia -i run/run_nf.jl", the error following error is displayed "Could not determine command" - julia

When I input the command
"julia -i run/run_nf.jl" the error "could not determine command" is shown.
before the error is shown this is how my cd looks like:
After activating the project with the command "activate." The following text is displayed in purple color ""
Finally with the command "julia -i run/run_nf.jl" I run the script "run_nf.jl" that is located on the folder "run". However, instead of running the script the following error is displayed.
The instruction for running and installing the necessary pachages are described in detail here:
Instruction, which I am based to run my script

As #fredrikekre mentioned in the comments, you are trying to run a terminal command from the Julia REPL's PKG mode, which will not work. You have two options:
Run the command from inside the REPL's shell mode by first using the "delete" or "backspace" key to exit out of the Pkg mode (you will see the prompt change) and then typing in ; which switched the REPL to shell mode and then you can run that command.
Same as above in that you need to exit the Pkg mode by clicking the "delete" or "backspace" key on you computer, and then you can run (from the REPL) include("run/run_nf.jl") which will run the file (assuming that is the correct file path).
I will also make a PR to that package you linked above to update the docs to be more clear. Edit, link to PR: https://github.com/dynamicslab/NormalFormAE/pull/7

Related

How to fix zsh: corrupt history file /home/mis/.zsh_history (Linux)

Whenever I open terminal I got his Warning!
[WARNING]: Console output during zsh initialization detected
When using Powerlevel10k with instant prompt, console output during zsh
initialization may indicate issues.
You can:
Recommended: Change ~/.zshrc so that it does not perform console I/O
after the instant prompt preamble. See the link below for details.
You will not see this error message again.
Zsh will start quickly and prompt will update smoothly.
Suppress this warning either by running p10k configure or by manually
defining the following parameter:
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
You will not see this error message again.
Zsh will start quickly but prompt will jump down after initialization.
Disable instant prompt either by running p10k configure or by manually
defining the following parameter:
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
* You will not see this error message again.
* Zsh will start slowly.
Do nothing.
You will see this error message every time you start zsh.
Zsh will start quickly but prompt will jump down after initialization.
console output produced during zsh initialization follows
zsh: corrupt history file /home/mis/.zsh_history
You can solve it by removing the package (purge) and reinstall it back.

I want to run magic command % somefile.py inside a jupyter notebook. However, this program requires variables from the main script

To clarify, somfile.py needs variables that are generated from main.ipynb. So, when I simply do %run somefile.py I get this error:
NameError: name 'viewer' is not defined
This viewer is defined in the main code above. However, now if I use %load somefile.py and THEN run it, it works fine. But, the whole point of me doing this is to not show the users of my script, the nitty gritty details. I am preparing this for some students.
The documentation of the magic command %run covers use of the -i option to "run the file in IPython’s namespace instead of an empty one." You want to add that flag to your %run command:
viewer = "something"
%run -i my_script.py
It applies to notebook kernel namespace as IPython was incorporated into the IPython notebook, which became the Jupyter notebook project later.

Bash Script function not showing segmentation fault for C program in ZSH [duplicate]

I have a program written in C that fails. When I run it in zsh, the program fails, but it's error output is not displayed in command line (note that the second ➜ was red, indicating a failed execution):
hpsc-hw2-USER on  master
➜ ./sort -a 405500
hpsc-hw2-USER on  master
➜
However, when I run it in bash, the error shows up:
[USER#COMPUTER hpsc-hw2-USER]$ ./sort -a 405500
Segmentation fault (core dumped)
Any idea why? I'm running oh-my-zsh with the spaceship theme if that helps.
but it's error output is not displayed in command line
That's not something that your program writes to the screen. It's the shell that's writing it. So the shell is not 'hiding' it.
I'm not using zsh myself, but since a red arrow indicates that the program was abnormally terminated, I guess you can look at the code for the red arrow and create a custom message. Here is a question about the error codes that might help you: What error code does a process that segfaults return?
I remember that I once made a custom bash prompt that showed the last exit code. Maybe I used this, but I'm not sure: Bash Prompt with Last Exit Code
Here is the documentation for how to customize the prompt for spaceship theme: https://denysdovhan.com/spaceship-prompt/docs/Options.html#exit-code-exit_code
I assume that you need to add exit_code to the SPACESHIP_PROMPT_ORDER section in your .zshrc file.
Any idea why?
You probably have to ask the developers. An equally valid question is: "Why does bash print 'segmentation fault'?" It's just a design choice. Bash does not print the memory address where the segfault occurred. Why is that?
Seems like the developers of oh-my-zsh thought it was enough with a red arrow.
Any ideas how to make zsh output the error message?
The result of the last command is stored in the shell variable ?, so you can print it with something like print $? or echo $?. Like most shells, zsh is incredibly configurable, so you can write a script that e.g. includes the result of the last command in your prompt. Here's a blog post in which the author configures zsh to display non-zero results in the right prompt: Show Exit Code of Last Command in Zsh.
Or why it doesn't do it to begin with?
Shell commands don't normally crash, and if they encounter errors they typically provide more useful output than just the return code on their own. The return code is most useful for scripts, so that you can write a script that handle error conditions.

Error that says Rscript is not recognized as an internal or external command, operable program or batch file [duplicate]

shell_exec("Rscript C:\R\R-3.2.2\bin\code.R ");
This is the call to script.On calling the above script, the error occurs.
I am trying to call my R script from the above path but no output is being shown. While checking the error logs of PHP, it says 'Rscript' is not recognized as an internal or external command, operable program or batch file.' The script is working fine on the Rstudio but not running on the command line.
Add the Rscript path to your environment variables in Windows:
Go to Control Panel\System and Security\System and click Advanced System Settings, then environment variables, click on path in the lower box, edit, add "C:\R\R-3.2.2\bin"
Restart everything. Should be good to go. Then you should be able to do
exec('Rscript PATH/TO/my_code.R')
instead of typing the full path to Rscript. Won't need the path to your my_code.R script if your php file is in the same directory.
You need to set the proper path where your RScript.exe program is located.
exec ("\"C:\\R\\R-3.2.2\\bin\\Rscript.exe\"
C:\\My_work\\R_scripts\\my_code.R my_args";
#my_args only needed if you script take `args`as input to run
other way is you declare header in your r script (my_code.r)
#!/usr/bin/Rscript
and call it from command line
./my_code.r
If you are running it in Git Bash terminal, you could follow a revised version of the idea suggested by #user5249203: in the first line of your file my_code.R, type the following
#!/c/R/R-3.2.2/bin/Rscript.exe
I assumed that your path to Rscript.exe is the one listed above C:\R\R-3.2.2\bin. For anyone having a different path to Rscript.exe in Windows, just modify the path-to-Rscript accordingly. After this modification of your R code, you could run it in the Git Bash terminal using path-to-the-code/mycode.R. I have tested it on my pc.
I faced the same problem while using r the first time in VS Code, just after installing the language package (CRAN).
I restart the application and everything worked perfectly. I think restarting would work for you as well.

SSHLibrary - A shell script with arguments exits with code 127 and error 'java: command not found'

Using Robotframework automation with ssh library, i am trying to execute a shell script with one argument (-a), on a remote UNIX box
The test steps are as follows:
Login to the UNIX box
Go to the directory where the shell script with argument (-a) is present
Execute the shell script
Please note:
Since 'SSHLibrary' keywords like 'Execute command' or 'Write' and 'Read' work in a single shell, i am passing multiple commands separated by a semicolon
In the series of commands, i also tried turning ON the shell using command shopt login_shell but this too did not work. Also note that the command shopt login_shell is not turning ON the shell when executed with 'Execute command' keyword. It works fine with 'Write' keyword
The following command to check if JAVA is loaded in the automation shell, returns a correct output (path to JAVA).
Write $JAVA_HOME
${Op_java}= Read
Problem:
Following robotframework test step after logging in to the UNIX box fails with exit code 127 and error 'java: command not found'
Method 1 that I tried:
Write shopt login_shell
${Op_Shopt}= Read
${Op_rc} ${Op_err}= Execute Command cd /home/xyz/abc; ./shell_script.sh -a return_stderr=True
Here the login_shell is turned ON but somewhere within the shell script the Execute Command keyword exits with code 127 and error 'java: command not found'
Method 2 that I tried:
Write shopt login_shell; cd /home/xyz/abc; ./shell_script.sh -a
${Op_shell}= Read
Here the login_shell is NOT turned ON and even here too the Execute Command keyword exits with code 127 and error 'java: command not found'.
As mentioned below, i also tried the same approach with the keyword 'Start Command', but still the same issue.
Start Command shopt login_shell; cd /home/xyz/abc; ./shell_script.sh -a
${Op_rc} ${Op_err}= Read Command Output return_stderr=True
Can someone please help me to resolve this problem?

Resources