Reputation: 12646
I have a directory named bin
that has a file called build-code
, file type is displayed as "file".
When opened with notepad, the code looks like this:
#!/usr/bin/env bash
set -e
rm -rf build
mkdir build
cp jspm_packages/system.src.js build/system.src.js
cp jspm_packages/system-polyfills.src.js build/system-polyfills.src.js
./bin/build-root
./bin/build-common-deps
./bin/build-home
./bin/build-navbar
./bin/build-angular1
./bin/build-react -p
./bin/build-angular2
./bin/build-vue
./bin/build-svelte
./bin/build-preact
./bin/build-vanillajs
When I try to run this file by navigating to bin
and typing in build-code
, I get the following error (PowerShell):
'.\bin\build-code' is not recognized as an internal or external command, operable program or batch file.
And bash:
$ build-code
bash: build-code: command not found
I have tried this in both PowerShell and GitBash. I have virtually no experience with writing scrupts for either (this is third-party code). What gives? Is this an invalid script, or am I doing something wrong?
As a side note, what is set -e
doing? Seems to be setting some var, but I have no idea why.
P.S. npm tag is on the list, because this was initially being called from npm, but I am trying manually now.
Upvotes: 0
Views: 499
Reputation: 169
Add the sha-bang {#!/bin/bash} line at the very top. (which you've done sort of)
Using chmod u+x scriptname make the script executable. (did you do this?)
Place the script under /usr/local/bin folder.
After that, you should be able to run the script. This is typically what I do in CentOS / RHEL when needing to write and run a small script. What exactly is your script doing? building a folder structure? If so this too can be done pretty easily with PowerShell too.
Upvotes: 0
Reputation: 464
Have you tried changing ./bin/...
to the absolute path?
Also, you mentioned navigating into bin before running the script, seems like the script expects to be run from the parent directory instead.
Upvotes: 1