N
N
newaitix2019-05-04 15:38:52
cmd/bat
newaitix, 2019-05-04 15:38:52

How to open a file from the command line?

in .bat

"%ProgramFiles%\Git\git-bash.exe" "F:\OSPanel\domains\logreel.com\upload.sh" "*"

In upload.sh file
git add compile release resource
git commit -m "$1"
git push

I am trying to pass a parameter from .bat to .sh.
But an error pops up.
5ccd8819a7ffe611668975.jpeg
How to overcome this trouble?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
res2001, 2019-05-04
@res2001

Obviously an error on the command:
Judging by the text - git cannot find compile.
It looks like you still need to do cd, because. you're running an extra shell, git-bash, and it has a default directory, most likely the user's home directory, not the one you're running it from.
It's easy to check - run git-bash manually from the command line without parameters and see what directory the pwd command will give.

I
Igor Deyashkin, 2019-05-16
@Lobotomist

So git status shows that the compile and release folders are a level higher. You need to either run the script from the root directory, or specify the paths not relative to the root, but relative to the launch folder. And it is better to go to a certain directory inside the script and use the paths relative to it.
The third option, in my opinion, is the most adequate, since otherwise it is easy to accidentally run the script from the wrong place and get the wrong result.
You can get the path to the directory in which the script is physically located, for example, like this:

scriptPath="$(readlink -f ${BASH_SOURCE[0]})"
scriptDirPath="$(dirname $scriptPath)"

In addition, only real-life folders / files should be passed to git add , otherwise your script will fall off on the very first command, as it does now. In this case, I don't see the resource file/folder , so even if you fix the paths, the script won't work because the resource is missing .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question