openapi-generator: command not found for bash script - bash

I have a generate.sh file with below lines of code,
#!/bin/bash
openapi-generator generate -g aspnetcore \
--template-dir ${PWD}/openapi-generator-aspnetcore3-templates/ \
--additional-properties aspnetCoreVersion=3.1 \
--additional-properties classModifier=abstract \
--additional-properties operationModifier=abstract \
--additional-properties packageName=RedHat.TodoList \
--additional-properties packageTitle=TodoList \
-i todo_openapi.yaml \
-o ${PWD}
When I am trying to run it Git Bash tool it's throwing error ./generate.sh: line 3: openapi-generator: command not found, I can see openapi-generator-cli commands working fine.

In generate.sh, replace openapi-generator with openapi-generator-cli instead.
(openapi-generator is usually installed via brew on Mac)

Looks like PATH problem.
Use which openapi-generator in terminal or Git Bash, whichever works for you, to find openapi-generator path first.
$ which openapi-generator
/usr/local/bin/openapi-generator
Then add the path to PATH variable in your generate.sh, e.g. put the following line before you call openapi-generator.
PATH+=:/usr/local/bin

Related

Invalid argument from bash script on MacOS command line

I'm trying to run the LiteCart bash installer script located here:
https://github.com/litecart/installer/tree/master/cli
Unfortunately, it's giving me a problem when I add preset arguments like this:
--document_root=/var/www/litecart/public_html \
--db_server=localhost \
--db_user=johndoe \
--db_password=mycatsname \
--db_database=mylitecartdb \
--db_prefix=lc_ \
--timezone=Europe/London \
--admin_folder=admin \
--admin_user=admin \
--admin_password=mydogsname \
--development_type=standard
I keep getting:
Error: Invalid argument (--document_root=/var/www/litecart/public_html)
My computer is running MacOS 10.15 and the server is running CentOS 7.9. The script runs fine without the arguments.
I can't find anything that even resembles this situation here. What's the proper way to run a script like this? Thanks.
Script contains no case for --document_root.
Try:
export document_root="/var/www/litecart/public_html"
./install.sh --db_server=localhost \
--db_user=johndoe \
--db_password=mycatsname \
--db_database=mylitecartdb \
--db_prefix=lc_
I assume that there are more problems in the script.

Passing Variables in Makefile

I'm using a Makefile to run various docker-compose commands and I'm trying to capture the output of a script run on my local machine and pass that value to a Docker image.
start-service:
VERSION=$(shell aws s3 ls s3://redact/downloads/1.2.3/) && \
docker-compose -f ./compose/docker-compose.yml run \
-e VERSION=$$(VERSION) \
connect make run-service
When I run this I can see the variable being assigned but it still errors. Why is the value not getting passed into the -e argument:
VERSION=1.2.3-build342 && \
docker-compose -f ./compose/docker-compose.yml run --rm \
-e VERSION?=$(VERSION) \
connect make run-connect
/bin/sh: VERSION: command not found
You're mixing several different Bourne shell and Make syntaxes here. The Make $$(VERSION) translates to shell $(VERSION), which is command-substitution syntax; GNU Make $(shell ...) generally expands at the wrong time and isn't what you want here.
If you were writing this as an ordinary shell command it would look like
# Set VERSION using $(...) substitution syntax
# Refer to just plain $VERSION
VERSION=$(aws s3 ls s3://redact/downloads/1.2.3/) && ... \
-e VERSION=$VERSION ... \
So when you use this in a Make context, if none of the variables are Make variables (they get set and used in the same command), just double the $ to $$ not escape them.
start-service:
VERSION=$$(aws s3 ls s3://redact/downloads/1.2.3/) && \
docker-compose -f ./compose/docker-compose.yml run \
-e VERSION=$$VERSION \
connect make run-service

Bash/WSL2: Is it possible to send files into the Windows directory from Linux?

#!/bin/bash
youtube-dl \
--ignore-errors \
--no-playlist \
--prefer-free-formats \
--no-call-home \
--extract-audio \
$1 \
--output 'C:\Users\Daniel\Music\Other\$2.%(ext)s'
Right now this script just puts the downloaded file into PWD, with that entire string as it's name. My question is:
Is it possible to use a Windows folder as a destination, or is this a limitation of WSL?
Help is appreciated.
in the wsl the default mount point for C: is /mnt/c/
so change the last line to:
"/mnt/c/Users/Daniel/Music/Other/$2.%(ext)s"
double quotes (see comment from #CharlesDuffy)

Curl changes multipart/form-data path parameter

I try to send some multipart/form-data data using curl in a msys shell to a NAS named Synology. The form-data needs a parameter named "path" and must formated like "/dir/dir2". The slashes can't be changed.
My problem is, when i am using curl the path variable will be changed to "C:/git-sdk-64/dir/dir2" and i don't know how to prevent it. My command looks like this:
curl -X POST \
'http://url:port/webapi/entry.cgi?_sid=secret&api=SYNO.FileStation.Upload&method=upload&version=2' \
-F "path=/dir/dir2" \
-F 'overwrite=true' \
-F 'filename=#/c/Temp/test.txt'
Thanks to Daniel Stenberg's info i found out this is a "problem" with msys self. Msys fills up the path variable. Written down here http://www.mingw.org/wiki/Posix_path_conversion. The solution is to put an semicolon at the end of the path. The complete command now looks like this:
curl -X POST \
'http://url:port/webapi/entry.cgi?_sid=secret&api=SYNO.FileStation.Upload&method=upload&version=2' \
-F "path=/dir/dir2;" \
-F 'overwrite=true' \
-F 'filename=#/c/Temp/test.txt'

Grouping commands inside complex bash expression

I have access to a computing cluster (LSF) and the basic way to send stuff to the compute nodes is by doing:
bsub -I <command>
I had this in a file:
bsub -I ../configure --prefix="..." \
--solver=...\
--with-cflags=...\
&& make -j8 \
&& make install
However I just noticed that actually only the first command (configure) was running on the cluster, the remaining two were running locally. What's the best way to group the whole command and pass it to bsub?
Assuming the bsub you are referring to is the one documented here, you have two options:
Surround the entire command to be executed with single quotes (assuming you don't use a single quote anywhere in the command):
bsub -I '../configure --prefix="..."\
--solver=...\
--with-cflags=...\
&& make -j8 \
&& make install'
Feed the command to bsub's standard input, using a HERE document to avoid quoting issues:
bsub -I <<END
../configure --prefix="..." \
--solver=...\
--with-cflags=...\
&& make -j8 \
&& make install
END
Or, very similar to the second one, put the command into a file and provide the file as input.
bsub -I sh -c '../configure --prefix="..." \
--solver=...\
--with-cflags=...\
&& make -j8 \
&& make install'

Resources