I am trying to use this project (websocketd), but the third step is not working:
1-download the platform specific archive //done
2-extract files to folder of your choice or extract executable only // done
3-add the location of websocketd to your PATH variable
Currently i have this PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/www/cpu-stats/websocketd
But when i run this code:
websocketd --help
I will get:
bash: websocketd: command not found
websocketd location
/var/www/cpu-stats/websocketd
Any idea?
I think you should just add the folder "/var/www/cpu-stats" to your path without the executable file name.
Related
I'm not sure exactly what to call what I'm trying to do, but I have a node script that accesses a folder (./commands relative to the script file), but when I run the script from somewhere other than the folder, it is unable to find ./commands.
I.e. when I'm in the folder with the script in it, ./commands refers to \script-folder\commands, but when I'm on the desktop, the script looks in Desktop\commands and finds nothing.
Is there any way to tell the script to run relative to its own folder, or do I just have to hard-code the full location of the commands folder in the script?
./ means current working directory. you can check with pwd command.
You can use path.join(__dirname,yourpath);
I'm new to WSL and Linux, but I'm trying to follow installation instructions for rhasspy (https://rhasspy.readthedocs.io/en/latest/installation/#windows-subsystem-for-linux-wsl). I have run the make install command successfully and the next step says I should copy rhasspy somewhere in my path but I can't quite figure out what copying to path means.
When installation is finished, copy rhasspy.sh somewhere in your PATH and rename it to rhasspy.
I added it to path but nothing changed so I was wondering if there is something I'm doing wrong. Right now when I run rhasspy on wsl it says rhasspy.sh: command not found. Any help would be really appreciated!
What it says is, put it in some place where the system will look for it when you type its name without full path in the shell.
There is an environment variable PATH that contains all those locations, separated by a :. (Check out echo $PATH.)
So, the author of these instructions leaves it up to you whether...
You want to copy the file to a location of your choice that is already in the PATH, such as /usr/local/bin or ~/bin.
Usually ~/bin is a good choice because it is per-user and doesn't pollute the system.
(Note that the directory ~/bin is added to the PATH by your .profile file only if it exists, so if you don't have this directory yet and create it now, you need to start a new login shell or run . ~/.profile1 before you can use it.)
- OR -
You want to create a new directory specifically for this application (say for example ~/opt/rhasspy) and append that directory to the PATH variable.
This can be done by adding the line export PATH=$PATH:~/opt/rhasspy to your ~/.profile file. Then, start a new login shell or reload the file using . ~/.profile1 for the changes to take effect.
If the directory in which this file is currently located is OK for you to keep permanently, then you can also just add that directory to the PATH instead of creating a new one.
Note: The PATH always contains directory paths in which the shell will look for executable files. It does not contain the actual file paths!
1: Yes, technically it is "cleaner" to log into a new shell or to run that one export statement manually instead of using . ~/.profile because the latter will apply things a second time that were already done before, so for example it can end up with the same directory in the PATH multiple times in the current session. In most cases that is fine though.
PATH is an environment variable. When you launch env, you see the list of known environment variables on your system.
In order to add something to your PATH variable, you need to take the variable, add the mentioned directory (preceeded by a semi-colon, most probably, as a separator) and store this again as the PATH variable. This can be done as follows (own example):
export PATH=$PATH:/home/this_user
the "PATH" it is referring to in linux is just inside the folder called /usr/bin. when you type a command into the terminal it looks for a program with that name inside the location. im not sure if this is the PATH you are looking for but hope it helps
I run a lot of node projects and often have binaries located in:
.\node_modules\.bin
...relative to the projects folder. I'd like to be able to have PATH always include these directories, if they exist. I don't want to include other directories, just the one relative to the current directory. I'm familiar with
Add-PathVariable from PSCX and other Powershell basics, but how do I include a folder relative to the current dir in PATH?
Edit: as mentioned in the question, already, I expect the path to stay updated as the directory changes. This is not simply asking about how to use pwd.
You can use a relative path in Env:PATH and the binaries found will update dynamically:
Eg:
$env:PATH += ';.\node_modules\.bin'
Or with the PowerShell Community Extensions (PSCX):
Add-PathVariable '.\node_modules\.bin'
Unlike using $(pwd) the . is not immediately resolved to an absolute path, so PATH is always relative to the current working directory.
Testing this:
$ which uuid
C:\Users\username\Documents\myapp\node_modules\.bin\uuid.cmd
Then changing directory, uuid now refers to a program in a different dir:
$ cd ..\blog\
$ which uuid
C:\Users\username\Documents\blog\node_modules\.bin\uuid.cmd
It's also possible to persistently change PATH in the user or system environment:
[Environment]::SetEnvironmentVariable(($env:PATH + ';.'), 'User')
or
[Environment]::SetEnvironmentVariable(($env:PATH + ';.'), 'Machine')
Security note: when entering a command Windows will automatically search all directories in $env:PATH for files with one of the extensions listed in $env:PATHEXT and execute the first match it finds. Depending on where exactly in the search path you placed . that may even supersede system executables.
You may want to take a look at how to use package installed locally in node_modules for alternative approaches.
I managed to execute a bat file via Groovy in SoapUI with Runtime.runtime.exec("cmd /c C:\temp\test.bat") But I would like to have the bat file in a folder called scripts where my soapui-project file is.
Example:
Soapui-project file.xml
-- Scripts
--- test.bat
Runtime.runtime.exec("cmd /c Scripts/test.bat") doesn't work. I really need help here.
In a team, we share the project artifacts with different members and each may use different directory to copy them. So, in such situations absolute path in groovy scripts, like you mentioned, may not work if the directory gets changes.
To hand this, prefix of the path should be variable. And the rest of the path can fixed as the whole artifacts are still unchanged.
To handle that, use below which makes use of project directory as root and it gets that dynamically.
import com.eviware.soapui.support.GroovyUtils
def path = new GroovyUtils(context).projectPath
log.info "Project directory : ${path}"
Runtime.runtime.exec("cmd /c ${path}/Scripts/test.bat")
I am building a hubot script and I want to load a yml file in it.
I am using the yamljs npm package to read the YAML file.
The problem is that it allways says "No such file or directory" error.
If i put the absolute path it works.
What I am missing?
I am loading the file like this:
feeds = YAML.load('../feeds.yml');
Here is my directory structure:
Where are you executing the script from? In node, path files in fs are relative to process.cwd().
Relative path to filename can be used, remember however that this path
will be relative to process.cwd().
Sources: http://nodejs.org/api/fs.html, https://stackoverflow.com/a/16730379/1007263
Therefore, if your script is in the same directory as feeds.yml, you should probably:
feeds = YAML.load('./feeds.yml');
Otherwise, there might be a bug in YAML. In this case, you can simply use path to deliver the absolute path directly.
path.resolve('../feeds.yml')
Source: http://nodejs.org/api/path.html#path_path_resolve_from_to