I am trying to run mathematica with a terminal interface. This is so that I can submit a mathematica program as a batch job to a high performance computing cluster.
Currently I load mathematica using:
module load mathematica/9.0.1
and then type
mathematica
to run it. This however opens a GUI interface which I don't think can be submitted as a batch job. Is there anyway to achieve this baring in mind I have no sudo privileges etc
The documentation on the text-based interface to Mathematica is here:
http://reference.wolfram.com/language/tutorial/UsingATextBasedInterface.html
I know this thread is old but I want to share this for future users:
I have used Mathematica with a terminal interface. You need to write a Wolfram Language Script, which is simply a .wl file with Mathematica code in it. Once you have written your file, just execute it in your terminal like this:
Running the script file on Windows:
$ "%ProgramFiles%\Wolfram Research\Mathematica\11.1\wolfram" -script file.wl
Running the script file on Mac:
$ /Applications/Mathematica.app/Contents/MacOS/WolframKernel -script file.wl
Running the script on Linux:
$ wolfram -script file.wl
Related
I have a program running on armbian single board computer. The program starts with -b option during the startup of the system. I created this simple shell script
#!/bin/bash
#Myprog server start
sudo -b /home/myprog/myprog
This program is C written and it sometimes outputs some information with printf functions. But since it is started with -b option there's is noting in the console.
Now when I log in to the armbian via ssh with Putty I want to occasionally read the output of this program. Is it even possible?
Not exactly what you’re asking, but generally speaking it’s better practice to redirect output to a log file than to try to interactively look at the console output for a background app.
Something like:
sudo -b /home/prog/myprog >> /home/prog/log.txt 2>&1
Should do it.
Then view output with
tail -f /home/prog/log.txt
If it’s really important to you to run interactively without logs, I would suggest running it from within “screen” without backgrounding it.
screen
sudo /home/prog/myprog
Then ctrl-d to detach and let it run in background. screen -r to reattach.
The Visual Code remote SSH extension allows editing any remote file in the embedded terminal just using code <filename> which is super useful.
However when opening a file with sudo e.g. sudo code /etc/fstabs it returns
sudo: code: command not found
Is there any way to allow the use of code to any user?
I don't believe this is possible at the time of writing as it would require the underlying node which is running VSCode server to be running with sudo, which it is not.
I have opened a GitHub Issue here.
I'm trying to compile and test the azure-iot-sdk-c on a raspberry pi. How do I compile it on the raspberry pi and then run the E2E tests provided in the SDK?
In order to achieve this, there are a couple approaches you could take. You could download a cross-compiler for the Pi and keep the source code only on your development machine. Then when you wanted to run code/tests on the Pi, you would use the cross-compiler to produce an output that could run on the Pi, transfer the executables to the Pi, and return the results back to the development machine. This approach would probably be quite fast, and if your project contains many files, it might be a good way to go about it. Setting up a cross-compiler isn’t the simplest thing to do, but there are many documented cases online of people who have already done it.
The other approach would be to develop the source code on your development machine but build the code for the Pi on the Pi itself. This removes the need to set up a cross-compiler and it makes getting the test results back to your development machine very simple.
You can use your text editor to develop the code on development machine. Then rsync to transfer your source files to the Raspberry Pi. Finally, You can install Ruby and Ceedling (a C unit testing tool) on your development machine and on the Pi to assist in running tests. Here’s how to make it all happen.
Set Up SSH Keys
This step is important because it allows you to transfer files from your development machine to the Pi and execute commands remotely without having to type in a username and password every time. First, make sure you have an SSH key generated on your development machine. If you don’t, or if you’re not sure, check out this excellent GitHub article that explains how to generate one.
ow if you open up your ~/.ssh (or your/user/directory/.ssh on Windows) directory on your development machine, you should have a file called rd_isa.pub. This is the “public” piece of your SSH key. You need to transfer this file to the Raspberry Pi so that it can recognize you as an approved user. Do that with the following command:
scp ~/.ssh/id_rsa.pub user#remote.host:pubkey.txt
Make sure to replace ‘user’ with a username on the Raspberry Pi and ‘remote.host’ with the IP address of the Pi.
Once you’ve done that, you need to append the key to the “authorized_keys” file on the Pi. To do so you will need to SSH into the Pi and manually edit/create the file. That can be done as follows:
scp ~/.ssh/id_rsa.pub user#remote.host:pubkey.txt
ssh user#remote.host
mkdir ~/.ssh
cat pubkey.txt >> ~/.ssh/authorized_keys
rm ~/pubkey.txt
Install ‘rsync’
The next step is to install rsync, a utility that allows you synchronize directories between two computers. When we make changes on our local machine, rsync will transfer those changes to the Pi for testing. rsync is smart enough to only transfer files that have been updated since the last transfer, which will speed up the process. For rsync to work, it must be installed on both your development machine and the Raspberry Pi. To install it on the Pi execute the following command.
sudo apt-get install rsync
The process for installing rsync on your development machine will vary greatly depending on which OS you are running. On the Mac, it’s already installed. Some Linux distros come with it as well. Windows, on the other hand, is a little behind the game. Search Google for “Installing rsync on Windows” for instructions on getting it setup.
Install Ruby
Ruby is another component that needs to be installed on by the development machine and the target. Ruby is a scripting language that Ceedling uses to automate unit test execution. Again, refer to the all-wise Google for instructions on installing the latest version on your dev machine. To install Ruby on the Raspberry Pi use the following command:
sudo apt-get install ruby
Install Rake
Rake is a Ruby gem (package) that provides build automation support similar to ‘make’. Once you have Ruby installed, Rake is as simple to install as typing the following:
sudo gem install rake
Setup a Ceedling Project
Finally We can already write code locally and execute tests on our development machine using the command “rake test:all”.
The final thing we need to do is set up a custom rake task that will run tests on the Pi without having to manually SSH into it. Look in the root directory of your Ceedling project and you will see a file named Rakefile.rb. This is where we will put our custom rake task. Add the following to the bottom of the file:
desc "Run rake test:all on RPi with latest changes"
desc "Update the RPi with the latest changes on dev machine."
task :update_pi_source do
#send the latest changes to the pi
puts cmd = "rsync -r -v . #{REMOTE_RPI_USER}##{REMOTE_RPI_IP_ADDR}:#{REMOTE_RPI_PROJ_ROOT} --exclude=#{PROJECT_BUILD_ROOT}"
system(cmd)
end
desc "Run rake test:all in the project directory on the pi"
task :run_all_tests_pi do
#execute tests on the pi
puts cmd = "ssh #{REMOTE_RPI_USER}##{REMOTE_RPI_IP_ADDR} "cd #{REMOTE_RPI_PROJ_ROOT} && rake test:all""
system(cmd)
end
task :pi_test_all > [:update_pi_source, :run_all_tests_pi] do
end
This actually defines three rake tasks. The first one, update_pi_src, is the task that uses rsync to update the source code on the Pi. The second one, run_all_tests_pi, uses SSH to execute the necessary command to compile the code and run the tests on the Pi. The third task, pi_test_all, is just a wrapper that combines the first two.
Hope it helps.
I am trying to run a batch file from Jenkins but I can't get it to run.
In the pre-build step I have entered the file I want to execute but I get the stacktrace shown below. Jenkins doesn't recognize the cmd command.
How can I fix this?
Your Linux Jenkins slave doesn't support cmd. In order to workaround it you have several options (from better to worse):
Add a Windows slave to Jenkins and run cmd from there.
Port your batch file to bash or similar and run it from your Linux Jenkins slave.
Add some kind of DOS emulator (Wine, DOSBox, DOSemu) in your Linux Jenkins slave.
My advice: If you know Linux & Bash or you have no control of Jenkins go for option 2. Otherwise go for option 1. Avoid option 3.
You're trying to run CMD on a LINUX machine. either change the slave you're running to Windows machine or migrate the Batch script to shell script.
Good luck!
I am using windows XP operating system and cygwin is installed in my C drive.
I need to login to cygwin directly to my directory path which contains a makefile and also a bash script called build.sh in the same directory. So i modified the original cygwin.bat file and added the line as shown below.
#echo off
C:
chdir C:\cygwin\bin
bash --login "/cygdrive/E/scheme_31july/build/build.sh"
When i double click on this bat file i could see my script executing but not on cygwin shell but on windows cmd shell as a result I get errors for "make" command like "No rule to make target" as make comes bundled with cygwin.
And when I explicitly login to cygwin using default cygwin.bat file and execute my script by giving following commands in cygwin shell the script executes without errors.
Basically I want to write a bat file so that I can keep it anywhere in my PC and instead of manually openeing the cygwin prompt and typing commands like:
$ cd /cygdrive/E/scheme_31july/build/
$ sh build.sh
it should happen automatically. I sit possible to do so.
Regards,
Harshit
No rule to make target sounds more like make being executed in the wrong directory. make itself seems to be available and running as intended.
Try this:
bash --login -c "cd /cygdrive/E/scheme_31july/build/ && sh build.sh"
This should start a --login session (which should give you access to all the settings and tools you'd expect in a cygwin prompt environment), then execute the given shell command, which is the cd and sh you asked for. You could also write those two lines to a separate script file, and pass the name of that to bash instead of the full path to build.sh.
You could also try to cd into C:\scheme_31july\build in the bat file and then execute bash from there. Not sure whether bash will try to change path upon entering the login session. You can try whether things work without the --login, both for this approach and the one above.
#echo off
C:
cd C:\scheme_31july\build
C:\cygwin\bin\bash.exe ./build.sh
I'm not sure whether you want the session to turn interactive after that or not. In the above case, bash will terminate after the script completed, and might even close the window. You might have to add a read into build.sh to avoid that. If you want bash to turn interactive after executing some command, you can try using the --rcfile option of bash to execute some commands and then turn interactive.