Issue with running Bash script in linux. - linux

Im having an issue with a bash script i picked up from google code. I have all the dependencies installed and i have it setup to what i think is correct.
To run the code im typing into the console ./jasagerPwn.sh
The error its saying is
[!] FATAL: You must run jasagerPwn from inside the directory...
....WHAT DIRECTORY? I dont know what directory it expects me to run it from?
You can see the script i am using here: http://jasagerpwn.googlecode.com/svn/trunk/jasagerPwn

When you run the script, it looks in the current dir if you have something matching jasagerPwn. If not, the error you was encountering appears.

Related

Nest js failed to execute command: with 'node'

I'm trying to init my first NestJS project but met this fail:
-----------------------------------------
$ nest new testproj
⚡ We will scaffold your app in a few seconds..
'node' is not recognized as an internal or external command,
operable program or batch file.
Failed to execute command: node #nestjs/schematics:application --name=testproj --directory=undefined --no-dry-run --no-skip-git --no-strict --package-manager=undefined --language="ts" --collection="#nestjs/schematics"
------------------------------------------
Tryed to reinstall NodeJS, but no luck.
$ node -v
v16.13.1
$ nest -v
8.1.6
$ npm -v
8.3.0
Any help will be appreciated.
tl;dr:
If your PATH somewhere has a file in it and not a folder (can also be in the middle of a path, with some \other\stuff appended like C:\stuff\somefile.txt\stuff), then this can happen due to an error when Git bash is translating PATH before calling cmd.exe, resulting in part of the PATH not being forwarded and making binaries in that part "not found".
Details:
After some investigation via chat, it turned out that the root cause was a bad GRADLE_HOME environment variable.
Yes, Gradle has nothing to do with node.js or nest, but bear with me, this is one of those moments where a TV episode starts with a totally crazy scene and you wonder what the heck happened that led to this, and then you get "6 hours earlier..." 😁
So, Git bash obviously succeeded in finding node, because it ran the nest CLI (which is a node script). But then, somehow, cmd (which is called by node when executing shell commands) did not find node. This normally should not happen.
Tracing the events with Process Monitor revealed that bash (sh.exe) passed a truncated PATH variable to node.exe. It just ended abruptly somewhere in the middle, and C:\Program Files\nodejs (which was towards the end of it) was not passed along.
The reason for this turned out to be an entry in the PATH that looked like this: C:\foobar\file.zip\bin. The transition into bash worked, as the full path (including this bad entry as /c/foobar/file.zip/bin) could be seen in bash's $PATH, and /c/Program Files/nodejs was there too.
But the transition from bash to node.exe failed. In the process of converting the Linux-style paths to Windows-style paths before passing the variable on to node.exe, bash silently failed in the middle of the string and stopped processing it - as soon as this /c/foobar/file.zip/bin entry was encountered. C:\foobar\file.zip did exist, and it turns out Git bash behaves like this when it unexpectedly encounters a "not a directory" error from the OS when querying the path segment ("file not found" is fine) - as a result of attempting to access a "subdirectory" of a file. Removing this entry from the PATH made everything work normally.
The source of this entry was actually %GRADLE_PATH%\bin in the Windows PATH, and the reason this caused the problem was that GRADLE_PATH itself was incorrectly set to a file (C:\foobar\file.zip) instead of a directory.
There are three ways to resolve this:
Remove %GRADLE_PATH%\bin from the PATH.
Fix GRADLE_PATH to point to a directory.
Delete or rename the C:\foobar\file.zip file.

Adding a command line script to the user environment whilst installing an application using electron-builder

I'm currently working on a project with Electron 9.0.4 and Electron-Builder 22.8.0 and am faced with a problem that doesn't seem too difficult but there isn't a valid solution online! (At least I couldn't find it)
I have my main program that does all of the UI tasks, and a command line script that does some backend. The reason I have this command line script is so that I can run certain parts of the application without opening the window itself. Everything works fine on my computer. After running npm link, my CL script is added to my environment variables and I can just run it from the console. However, when I try to build with electron-builder, the problem occurs.
If I use my Setup.exe on another computer, the command line script just won't be added to the environment variables and I couldn't find instructions on how to do this in the electron, nodejs, or electron-builder documentation. What I found was a suggestion on another question to add npm -g install as a post-install script, but that had no effect either.
Someone else suggested adding npm link as a post-installation script, but firstly if I am not mistaken this function is not intended for production and secondly it created an infinite loop as npm link triggered the post-installation script over and over again.
Thats how the script is added to the project
"bin": {
"command-name": "/cl.js"
}
Any help is appreciated!
Since I couldn't find a direct solution to my problem and didn't want to look any further for a solution while being able to take a different approach.
I decided to take a step back and look for another method to solve my problem I came to the conclusion that I didn't really need to add a script to the command line. My solution was to look for a certain argument when starting the regular application.
if (process.argv.includes("cli")) { /* Do commandline stuff */ }
When the custom argument is found, I simply run the script that should've been run from the command line. Using this approach, you can create a shortcut to my executable that contains the custom argument and then instead of the application it runs the command line script.

Matlab Libopencv error using Linux

I am running into errors with opencv. I downloaded a package online and compiled each of the folders by cd into them and running make through the command line. But when I try using one of the functions, I run into this error: libopencv_core.so.2.3: cannot open shared object file: No such file or directory
The file its trying to reach is indeed there, since I checked this, but for some reason its saying its not. I am pretty bad at figuring out path problems but I think this is one of them. Can anyone tell me how to fix this? Thanks

Command "docpad run" is getting error: "module" is undefined

I've migrated my configurations from docpad.coffee to docpad.js (personal preference on using plain Javascript)
Since then, I'm not being able to execute the command
docpad run
And I'm keep getting this error:
I've validated my configurations against JSLint and made sure there's no syntax error.
I'm good to go with docpad.coffee, but it'd be great if someone could help me on fixing this
You can use docpad.cmd run instead of docpad run to distinguish between the local docpad.js and the global npm-installed docpad.cmd.
This is because windows recognises the ".js" extension as a javascript file and tries to run your docpad.js file when you issue the "docpad run" command. Windows script host is what is used by windows to run js files natively (so actually nothing to do with node or docpad itself). The reference to "module" in the error message is because that is the first line of the docpad.js file and the windows script host doesn't know what "module" is. You can just rename your docpad.js file to .coffee (I believe all javascript is valid coffee script) and then the windows message will disappear.
Edit: I've just went and tested this on the docpad skeleton which has a docpad.js file instead of docpad.coffee. Simply renaming it to docpad.coffee does indeed solve the problem. Renaming it back to .js then causes the 'Windows Script Host' error message to appear when the "docpad run" command is issued.

Having trouble with post-commit hook

I am following this tutorial that is like the hello world for post-commit
I am using Ubuntu 10.04. I installed svnnotify and ran $ which svnnotify which output:
/usr/bin/svnnotify
so I changed the path in the turorial from /usr/local/bin/svnnotify to /usr/bin/svnnotify
I also tried changing the line: #!/bin/sh to #!/bin/bash since bash is the login shell in ubuntu 10.04.
I tried to run it the way the tutorial originally had it, with my changes, and combinations of the two.
Every time the commit is successful but I get
Warning: post-commit hook failed (exit code 1) with no output.
The original way had output not found
I am very new to linux and shell scripting and have exhausted everything I can think of. What am I doing wrong?
Get the script working and tested before trying to run as a commit hook. I expect that your problem is something to do with the script, maybe not being marked as executable, environment wrong, etc.. i.e. if you can't get it to run successfully from the command line, this is more of a unix/shell question and doesn't really have anything to do with SVN (yet).
I'm not sure whether this applies in the Linux world, but in the Windows versions of SVN I've used, the code which runs the hook scripts only captures STDERR. If your hook script is only writing messages to STDOUT, that would likely explain the "No Output" warning.

Resources