Calling Bash scripts from Matlab with W10 Linux subsystem? - bash

I am making routinely system calls from Matlab (R2016b on W10 64) to integrate some ImageMagick functions. Now I have just read about the existence of the W10 Linux subsystem. Is it possible to call with this option given Bash scripts from Matlab that implement themselves long ImageMagick processing pipelines? And if yes how?

You can run a script from Matlab using !<script> or system(<script>). See this or this for calling convert as an example.

With
bash -c "command"
one can access the Bash shell from the Command Prompt, PowerShell, or elsewhere in Windows so this could be the way to call a Bash script from Matlab link .

Related

/bin/bash: No such file or directory when running a shell script from Matlab

I'm creating a Matlab code in windows 10, which in turns uses the Ubuntu environment (inside windows 10) to perform some calculations mixing Matlab and OpenFOAM.
I summary, what I do is that I have a Matlab code, which at certain moment calls a shell script function inside my ubuntu environment and this function perform everything that I need on ubuntu. If I test that .sh file inside the ubuntu environment it works flawless, but when I call it from Matlab (on windows 10) it doesn't work.
In Matlab my call is done like this:
system('bash -c "******.sh"');
and I receive the following error
/bin/bash: ******.sh: No such file or directory
even if the file exists.
Any clues?
Sorry, I was out of the country, but yesterday I was able to solve the problem.
The reason to use both software that way is that I need OpenFOAM to work in its native configuration.
That said, it seems that my problem was due to the fact that windows allows you to install bash and Ubuntu at the same time, so when I asked to Matlab to perform a system('bash -c "******.sh"') it tried to use bash whilst I had everything installed on Ubuntu. So the solution was simply to delete bash of my Windows10 installation.

How would I interface with the Linux terminal (bash for windows) using windows command prompt?

I just recently found out about using bash in windows. I had alot of fun installing linux programs onto my windows computer using bash and wondered how I would be able to run an automatic script so I dont have to export my display everytime I open bash.
I used to write scripts for cmd called batch scripting and I would be able to do everything cmd could do. Now that I have access to bash, I want to script a program that connects useful pieces of cmd with useful pieces of bash but I Can't find any results telling me how to call bash commands from cmd. Thank you - Zak Kaioken

Run the shell commands in Perl using system() function in Windows

I am migrating some plugin from Linux to Windows.
Plugin is written using Perl and it has the function called system() that will execute the shell commands.
But I am migrating to Windows now. Any way I can run the linux command in windows using system() Per function?
Some Perl Module avail for this ?
You can run the system() command but there are caveats. A nice description is contained in Using system or exec safely on Windows. This article resulted in the Win32::ShellQuote module.
You want to run a linux command vie Perl in a windows shell? If so, try a Linux environment like Cygwin (www.cygwin.com). Otherwise you have to migrate your system calls as well.

how to start a new session in a shell script in platforms other than Linux?

I have this problem:
I have a script A, and it calls another script B, but this script B must run in another session, it is an easy job to do in a C program with setsid
(), but I cannot find an equivalent shell command. There is a setsid shell
command in Linux, but there are no such commands in AIX and other UNIX
platforms. Can anyone give me some advice on how to do it in AIX and other UNIX platforms? Thank you.
The setsid() system call exists in FreeBSD and OpenSolaris, and is part of POSIX.1. So I would think that it should exist in anything that claims to be POSIX-compliant.
AIX is fully compliant with "one or more" of the POSIX standards, but I've never used it, so I can't comment on it directly. Since it's a vendor-supported operating system, I recommend you touch base with your vendor.
Now.. What do you mean by "an equivalent shell command"? What do you mean by "session" in the context of a shell script? If what you're looking for is a way to run a second shell script with a separate controlling terminal from the original script, I suggest you look at GNU Screen instead of system calls. Screen should be available for AIX.
If you have a shell script that currently works for you in Linux, and you're trying to port it to other platforms, then include the script in your question. Otherwise, we're flying blind.

Run a shell script on Windows - Drupal install using DAMP

i've installed DAMP on Windows Vista, and have created a profile in my drupal folder with a shell script that needs to run.
profiles/donor_rally/rebuild.sh
However, I don't know how to execute this shell script.
I am not familiar with shell script command language, would you be willing to provide me with a step-by-step instructions on how to execute this shell script?
Thanks.
It looks like you're trying to run a Bourne shell script, which would usually only run on a unix machine. Guessing from the name, this is supposed to rebuild something, likely the database, but that's just a guess.
The short answer is you can't run it, at least not easily. If you were to post the (edited) contents of the script you might get some answers about how you could port it to a Windows cscript or batch file.
For others who are uninitiated to shell scripting in Windows:
I did not find a straightforward solution for running shell scripts on AMP hosted on Windows.
Instead I got an account at webenabled.com
Then used PuTTy to tunnel in.
I found this guide to using UNIX: http://freeengineer.org/learnUNIXin10minutes.html
And lynda.com

Resources