Cygwin path to /cygdrive/C/Program Files (x86)/GnuWin32 directory? - cygwin

I am having trouble executing a program located in the "C:\Program Files (x86) directory in Windows from within Cygwin. Anyone know the trick to getting this to work?
jboss#QA024 /cygdrive/C/jboss/EAP-6.0.1/jboss-eap-6.0/bin
$ wgetexe="/cygdrive/C/Program Files (x86)/GnuWin32/wget.exe --help"
jboss#QA024 /cygdrive/C/jboss/EAP-6.0.1/jboss-eap-6.0/bin
$ bash $wgetexe
bash: /cygdrive/C/Program: No such file or directory
jboss#QA024 /cygdrive/C/jboss/EAP-6.0.1/jboss-eap-6.0/bin
$ bash "$wgetexe"
bash: /cygdrive/C/Program Files (x86)/GnuWin32/wget.exe --help: No such file or directory

Try this:
wgetexe="/cygdrive/C/Program Files (x86)/GnuWin32/wget.exe"
"$wgetexe" --help
Since it's an executable, you don't want to pass it as an argument to bash, which will try to execute it as a script. Since it has spaces in the path name, you need to quote the name so the shell doesn't try to execute cygdrive/C/Program with invalid arguments.
You should also be able to add the directory to your $PATH:
PATH="$PATH:/cygdrive/C/Program Files (x86)/GnuWin32"
Keep in mind that GnuWin32 programs are Windows executables, and any file paths they use will be interpreted using Windows syntax. Cywin executables (anything that uses cygwin1.dll) use Cygwin path syntax.
Better yet, install the Cygwin version of wget and just invoke it as wget --help.
For example, if you're using the GnuWin32 wget, you might use:
wget -O "C:\cygwin\home\yourname\output-file" "$url"
whereas with the Cygwin wget you might use:
wget -O "/home/yourname/output-file" "$url"
I've always found it easiest to use Cygwin executables from Cygwin whenever possible.

Try this, it always worked or me.
wgetexe="/cygdrive/C/Program\ Files\ \(x86)/GnuWin32/wget.exe"
"$wgetexe" --help

Related

How to use nvim command if neovim is installed using appimage?

I have installed nvim using AppImage mentioned as below
curl -LO https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage
chmod u+x nvim.appimage
./nvim.appimage
if i use nvim test,yml ,it fails as '-bash: /usr/bin/nvim: No such file or directory'
if i use ./nvim.appimage test.yml then it works. How to map this to nvim so that it works properly?
Linux looks for binaries in the paths that are set in $PATH variable. To check current paths execute echo $PATH
One way to fix it would be to move nvim.appimage (and rename it to just nvim) to one of the paths set in that variable.
Another way is to append the current path of nvim.appimage to $PATH. This was answered in detail How to correctly add a path to PATH?

Path, /usr/bin/ and /usr/local/bin/

I installed watchr on OS X (10.8.3) using gem install watchr. And it's installed in /usr/bin/watchr
$ which watchr
/usr/bin/watchr
However, when I tried to call it $ watchr -v, the system couldn't find it.
$ watchr -v
-bash: /usr/local/bin/watchr: No such file or directory
I think this is related to how the path is set up on my machine. My questions:
What is the right way to fix it?
In general, what programs should go to /usr/bin/ vs. /usr/local/bin/?
When I do e.g. $ /usr/bin/watchr -e 'watch(./hello.txt) ...', are we looking at the hello.txt in the current directory or in /usr/bin/ i.e. the same directory as watchr?
The path to your command was cached with a bad value. Try to update the cached directory that bash has stored for the path.
hash -d watchr
I found the answer over here which ctags shows /usr/local/bin/ctags but when I run ctags it runs /usr/bin/ctags. How is this possible?
Is /usr/local/bin/watchr a broken symlink? That would make which watchr not include it but watchr would print this error:
-bash: /usr/local/bin/watchr: No such file or directory
I don't know why the gem that comes with OS X installs programs in /usr/bin/, but generally /usr/bin/ is meant for preinstalled programs, and package managers use something like /opt/local/bin/ or /usr/local/bin/.
I also have /usr/local/bin/ before other folders on the path, and I put most programs that I install or compile manually to /usr/local/bin/. I used to have a separate ~/bin/ folder, but it's easy to find non-Homebrew programs with something like find /usr/local/bin ! -lname '../Cellar/*'.
Related questions about /usr/local/bin/ in general:
https://unix.stackexchange.com/questions/8656/usr-bin-vs-usr-local-bin-on-linux
https://unix.stackexchange.com/questions/4186/what-is-usr-local-bin-came-across-it-in-an-script-installation-for-applescript
create a file called .profile in your home directory and add the following line.
export PATH=“/usr/local/bin:/usr/local/sbin:/usr/bin:$PATH”

What does it mean in Linux for installing script

I am trying to install some scripts into linux and follwoing line is given as instruction.
Install the xyz script into some convenient directory in $PATH.
but I'm unable to understand what exactly does it mean.How do I install given script in $PATH directory.Script is placed under /users/username/ Dir.
In a terminal type echo $PATH. You will see a list of directories. Put your script, or a link to your script in one of those directories, typically in /usr/local/bin.
its a bad description of the script-author :) usually, in your $PATH are multiple directories mentioned, separated by colon.
you can echo them:
echo $PATH
What the Author means: just copy the script in a directory which is in your $PATH, e.g. /usr/local/bin
$PATH is a list of directories where bash looks for executables.
The given instruction suggests that yours scripts should be put in one of these directories.
An alternative is to put your scripts in any directory and add that directory to $PATH. In your case, add the following line in your $HOME/.bash_profile configuration file:
export PATH=$PATH:/users/username

How can I prevent finding executable on $PATH?

I am using a system with an incomplete installation of GNAT, the GNU Ada compiler. A script (in the gdb testsuite) is finding /usr/bin/gnatmake and assumes that it can run Ada compiles. These fail because a the linker can't find libgnat.so.
I don't have root access, so I can't install libgnat.so or remove /usr/bin/gnatmake.
Is there any way to prevent a script from finding gnatmake in /usr/bin? I clearly cannot remove /usr/bin from the path.
Can you install a private, working version of gnatmake?
If you can, then you can create a symlink to the working version of gnatmake in your $HOME/bin directory:
ln -s /path/to/real/gnatmake ~/bin/gnatmake
Then insert your own $HOME/bin directory into your $PATH:
export PATH="$HOME/bin:$PATH"
Now the shell will find your version of gnatmake before the one in /usr/bin.
Try sudoing the script as yourself (sudo -u you ./script). In case you're not allow to sudo, you can also try exec VAR=val ./script. A third way would be to add another directory to $PATH with 'fake' empty scripts to shadow the ADA files.

Running files in Linux terminal

On a Mac one can run any downloaded executable in the terminal using just the executable name. On Linux, such as Ubuntu, by default one will have to specify the directory to run in.
Mac example: sbt
Linux example: ./sbt
What do I need to set in Linux so that I don't need the ./ in front of the executable?
This should work:
PATH=$PATH:.
or in bash:
PATH+=:.
You can define an alias in your .bashrc file if it is an often used file. Or just add the directory in which your files is located to your $PATH var.
Copy your script in /usr/local/bin

Resources