Reputation: 115
I am trying to run a shell script which takes a list of input arguments from command line on Windows. Most (all?) questions related to running shell scripts on Windows simply point the user to cygwin/git/anaconda tools. However, for my purposes, I need to find a way to run the shell script specifically from the command line. The reason being is that I would like to run this shell script via Matlab. Matlab has the system() command which allows you to run commands from command line.
I am close to a solution, but I am having trouble getting my input arguments to be read properly. Here is my call to the command line:
C:\Users\qualiaMachine> C:\cygwin64\bin\bash --login -c "W:/code/bashScripts/pre/zipAllSingleChOutput.sh" 1
The format of this call follows the instructions I found here, with '1' begin the only argument: https://www.mathworks.com/matlabcentral/answers/221901-can-i-call-a-bash-shell-script-using-cygwin-through-matlab
Similar to the OP from that post, I was unable to get my script to accept input arguments. I have a line in the shell script,
echo "$#"
which I'm using to determine if arguments are passed properly, and I've had no luck so far. I also should mention that I'm testing this through command line rather than calling system() through Matlab at this point (simply to run a more direct test). Any ideas how to resolve this issue?
Upvotes: 0
Views: 268
Reputation: 115
Oy vey. The solution was as simple as moving the double quotation to come after the list of input arguments.
C:\Users\qualiaMachine> C:\cygwin64\bin\bash --login -c "W:/code/bashScripts/pre/zipAllSingleChOutput.sh 1"
Upvotes: 1