How to run matlab m-file script on a linux server - matlab

I am new with using servers and currently, my PC has Windows 10 and Matlab 2016b. I have very long Matlab codes saved as m-files and when running these m-files on my PC, it takes a long time.
However, I can access our Linux server using Putty with a given ID and password. So, how I can run my Matlab codes on our server instead of on my local PC?

Assuming the Linux server has Matlab installed on it as well, (and that it has also been added to the path on the server), you can run your Matlab scripts from the terminal, simply by entering in the terminal, $ matlab your_script_name.m.
Also, there is the option to start Matlab on the remote server in command-line mode, by typing at the prompt $ matlab -nodesktop.
Finally, if you want to know a way on how to get your m-files from your PC to the remote Linux server, you can use a tool like winscp, which is often present in the company of putty.

Related

Matlab connection to a remote server

Is there a way to connect to a host through matlab using SSH? The way that can be done in vscode for example.
I have script and data in the remote machine but matlab license in my local machine. I would like to run the matlab scripts using matlab installed on my laptop.
Alternatively, I clone the scripts on my laptop run them while processing the data located in the remote machine.
https://en.wikipedia.org/wiki/SSHFS
helps you mount a remote filesystem via ssh. So if you can login from your matlab laptop to the data pc via ssh , then sshfs is one step more. From there your data is a path on the matlab laptop.

How to run initialization commands after SSH in VS Code Remote?

Problem
I am trying to connect to my school's computing cluster (aka a linux server with "login node" and "computing node") using VS Code's Remote SSH, but I cannot figure out how to run a command after SSH-ing.
Goal
I simply want to view Python code and test some small lines in a .ipynb jupyter notebook in the computing platform's environment.
Description
Basically, normally in the command line (or mobaXterm of a Windows machine) of my local machine, I first log onto the computing platform's login node with ssh -Y -L PORT:127.0.0.1:PORT username#computing.cluster.ip, and then run srun -t 0-12:00 --pty -p gpu --gres=gpu:1 --x11 --tunnel PORT:PORT /bin/bash to log onto the computing node interactively (shown command allows for port forwarding). The problem is, in VS Code I can only connect to the login node, but after that there's no way for me to run another command and log onto the computing node. The reason I need to get to computing node is that I want to test something with a .ipynb file interactively on VS Code while reading the code, and the login node does not allow me to perform computation.
Failed trials
I've been trying Code-Server, but it does not support .ipynb well (it keeps asking me to install jupyter notebook even though I have installed it in my conda env), possibly because it by default recognizes HPC cluster's Python interpreter which I cannot modify (I can't even select Jupyter kernel in code-server). I also tried to directly use Jupyter Notebook (open Jupyter with port forwarding after getting onto computing node), but reading code on it is much more inconvenient.
Would greatly appreciate your suggestions!

Run the Mechanize::Firefox script in VNC server using Net::SSH::perl?

I have done the script with Mechanize::Firefox. I need to run the script in VNC server. I'm working on ubuntu. I have installed krdc software to run the scripts.
Before running the script I'm starting the vnc server by using the following command vncserver.
To connect the server via ssh I have using one password for example sshpassword. When open the krdc software there I'm using the vncpassword.
My problem is, I have trying to run the Mechanize::Firefox script using Net::SSH::perl script it is running but the firefox is not starting. So I cannot crawl the content.
How can I fix this issue.? I don't know from where need to start.

Debugging Windows Kernel from Linux

I used to debug the Windows Kernel using VirtualKD, WinDBG and a single Virtual Machine.
Recently I got a Linux machine, and now I wonder- What's the easiest way to debug the Windows Kernel when your host is unable to run VirtualKD/WinDBG*?
I assume the solution will require two Virtual Machines, but I rather have two instances hosted on my actual machine rather than having an instance residing inside another virtual instance...
Is there anyway to make that work?
Thanks in advance!
*Wine is the last resort for stability reasons...
Solved! Basically, I ended up using two (VirtualBox) VMs emulating a Serial connection (null-modem cable) over a Unix domain socket (on the host). For more info, read below:
Hardware setup*:
Debuggee:
Ensure the machine is turned off and edit Serial Ports settings.
Enable Port 1, and assign values as follows: Port Number: COM1, Port Mode: Host Pipe, Create Pipe: Unchecked (client), Port/File Path: /tmp/win_link.
Debugger:
Same as above (using the same path), only this time Create Pipe should be Checked (server).
Debugger setup:
Run WinDBG and press Ctrl+K to invoke Kernel Debugging.
in COM, enter: Baudrate: 115200, Port: COM1, Resets: 0 and verify that Pipe and Reconnect are unchecked (important).
You'll be presented with the following output: Opened \\\\.\com1 Waiting to reconnect...
Debuggee setup:
Run bootcfg /debug on /port com1 /baud 115200 /id 1. To verify, run bootcfg.**
Reboot.
Quite early during the booting stage, WinDBG on the other machine should detect the debuggee is running.
*Assuming VirtualBox is used. VMWare/KVM users will probably be able to achieve the same results following similar steps. Also, for more info refer to the VirtualBox docs.
**Assuming guests are Windows XP. Later versions include bcdedit, which may be used as described here.
For QEMU\KVM follow those instructions:
http://www.linux-kvm.org/page/WindowsGuestDrivers/GuestDebugging
Very helpful but applies to Windows XP machines. You can refer to the following link if you need to configure 2 Windows7-based virtual machines on a Linux host: http://www.aldeid.com/wiki/Category:Digital-Forensics/Computer-Forensics/Debugger/Kernel
Another option nowadays is to enable local kernel debugging. This comes with some limitations, however it will enable you to access kernel data while just using one VM.
This approach only works on Windows 8.0 and Windows Server 2012 and later.
Follow these steps:
Open a Command Prompt window as Administrator.
Enter bcdedit /debug on
If the computer is not already configured as the target of a debug transport, enter bcdedit /dbgsettings local
Reboot the computer.
Once the system is rebooted, you can execute WinDBG as Administrator, press ctrl+k or go to File -> Attach to kernel -> Local and press OK.
At that point, you will be able to execute kernel-only commands and access kernel structures:
Tested under Windows 10 and with the new WinDBG version (preview).
Reference: Setting Up Local Kernel Debugging of a Single Computer Manually

Is it possible for Emacs to run a Matlab shell that is located on a remote server?

I would like to be able to use Matlab-mode (matlab.el) to run a matlab shell. The only problem is, Matlab is located on a remote host. Is this even possible? If so, please explain. I'm currently playing around with tramp but to no avail.
Thanks.
I just tried using the emacs matlab mode through ssh, no problem
had to make a script which loads matlab, couldn't just specify the command in matlab.el
so:
/home/second/remoteMatlab:
#!/bin/bash
ssh orac matlab -nodisplay
where orac is the host which has matlab. you can pass commands to ssh here. i use ssh config and key authentication so only need the hostname here
in matlab.el, find
(defcustom matlab-shell-command
and set to eg
(defcustom matlab-shell-command "/home/second/remoteMatlab"
I am not 100% sure what you are doing, but this seems possible. If
you use Tramp (or sshfs, my personal choice) to edit a script on a
remote machine, you will be able to run it on that remote machine. If
you have a *shell* buffer open, it can easily be ssh'd to that remote
machine. If you are doing something REPL-like where emacs sends input
to this buffer that's connected to a process over ssh, it should still
work. If it is communicating with a remote process over a socket, you
can use ssh forwarding to make the socket appear local.
Anyway, there is not much gap between local and remote, so this should
all work out.
Finally, to toe the (GNU) party line... have you tried Octave running locally?
#Yotham : I can't comment yet on earlier answers, but your problem (Script working, malab-shell command in emacs not) may be due to the fact that you didn't delete/rename your matlab.elc file?
This way emacs never gets to know of the change since it prefers .elc over .el files for speed.
Resolved the same issue for me.
cheers
tnt