Cygwin program compiled but not runnable - bash

I just installed CD-HIT and followed these instructions:
Installation
Most CD-HIT programs were written in C++. Installing CD-HIT package is very simple:
download current CD-HIT at http://bioinformatics.org/cd-hit, for example cd-hit-2006-0215.tar.gz
unpack the file with ” tar xvf cd-hit-2006-0215.tar.gz --gunzip”
change dir by “cd cd-hit-2006”
compile the programs by “make”
you will have all cd-hit programs compiled
I followed these steps and indeed .exe files were made:
cdhit.c++ cdhit-est-2d.c++ clstr_select_rep.pl
cd-hit.exe cd-hit-est-2d.exe clstr_size_histogram.pl
cdhit.o cdhit-est-2d.o clstr_size_stat.pl
cdhit-2d.c++ cd-hit-para.pl clstr_sort_by.pl
cd-hit-2d.exe cdhit-utility.c++ clstr_sort_prot_by.pl
cdhit-2d.o cdhit-utility.h clstr_sql_tbl.pl
cd-hit-2d-para.pl cdhit-utility.o clstr_sql_tbl_sort.pl
cdhit-454.c++ ChangeLog clstr2tree.pl
cd-hit-454.exe clstr_cut.pl clstr2txt.pl
cdhit-454.o clstr_list.pl clstr2xml.pl
cd-hit-auxtools clstr_list_sort.pl doc
cdhit-common.c++ clstr_merge.pl FET.pl
cdhit-common.h clstr_merge_noorder.pl license.txt
cdhit-common.o clstr_quality_eval.pl make_multi_seq.pl
cdhit-div.c++ clstr_quality_eval_by_link.pl Makefile
cd-hit-div.exe clstr_reduce.pl plot_2d.pl
cdhit-div.o clstr_renumber.pl plot_len1.pl
cd-hit-div.pl clstr_rep.pl psi-cd-hit
cdhit-est.c++ clstr_reps_faa_rev.pl README
cd-hit-est.exe clstr_rev.pl usecases
cdhit-est.o clstr_select.pl
However when I typ: cd-hit-est in the cygwin command line, it will say: -bash: cd-hit.exe: command not found. I'm not able to figure out why this is happening. Even when I'm in the folder were the .exe files are located it still will give the same error.

When you try to run command without a path, bash tries to find the command name in each directory from the PATH environment variable.
Usually current directory "." is not in the PATH so you have to run command adding absolute or relative path before command name:
./cd-hit.exe
or
/absolute/path/to/your/cd-hit/program/cd-hit.exe
If you want to permanently run command cd-hit.exe from anywhere, just add the directory where cd-hit was compiled to any existing auto-loaded bash profile files:
.profile
.bashrc
.bash_profile
like
PATH=$PATH:/absolute/path/to/your/cd-hit/program
export PATH

Related

Command not found in ssh but is in direcory

I am using an ssh account that connects to an external server, i have downloaded through guix some software like samtools and bedtools but when i try to use them in my directory it gives me this error:
-bash: samtools: command not found
In my direcory, however, there is the directry guix.profile and if I go into the bin folder of this, I have everything I downloaded.
What am I doing wrong?
Thank you
enter image description here
To run a file from the shell you need two things:
The shell must find the file
Being in the same directory does not enable the shell to find the file. You have to either supply an absolute or relative path the file, or have the directory in your PATH environment variable
In simplest terms this means instead of
$ samtools
try
$ ./samtools
The relative path tells the shell it wants that file
To run it from another directory, either use the whole absolute path, e.g. /home/yourname/samtools , or move the file into a directory that is on your $PATH
The file needs to be executable
If the file is not executable you will need
$ chmod +x ./samtools

'gawk' is not recognized as an internal or external command, operable program or batch file. but other files in the similar path can be run in Cmd

I wan to run a code which should be read in Cmd using gawk. I have installed it in my program file directory. I also have installed another file named Grep.exe in the same directory:
enter image description here
when I try to run codes with these files I can run grep in cmd but I cant run gawk which is in the same directory. see the picture:
enter image description here
I thought the problem is with the path so I tried different things.
1
defining the path in cmd with this command and this link
setx path "%path%;c:\directoryPath"
define path in windows env using this link
Installing in different directory and adding env path
renaming the gawk.exe to ggawk.exe and trying to run
installing in other computrs
none of them work.
I dont know what is the reason that it can read other files in the same directory but not this specific .exe file that I need.

Msys2 autocomplete doesn't work for current directory

I installed msys2-x86_64-20161025.exe following these steps.
When I try autocompletion for programs on the PATH, e.g. by typing g and then pressing TAB key twice, Msys2 console shows me a lot of options (.exe , .dll , and others).
However, when I type ./ and then press TAB key twice, it shows me only subdirectories of the current directory, but not .sh or .bat files in the current directory.
ls -al command shows that Msys2 doesn't see "executable" file permission on the .bat and .sh files. chmod +x * doesn't seem to work on Windows.
So how to get autocomplete to work in Msys2 for current directory script files?
I am on Windows 10 x64. Let me know if some additional info about the environment is needed.
If your script contains a shebang line, msys2 will recognize the file as a script. That's has been my experience at least.
Particularly for Bash scripts the first line of each script can be #!/bin/bash, if Bash is installed in /bin/. See more on Shebang line here.

Running an executable in Mac Terminal

I just made a .c file and compiled it with gcc in the terminal on OS X 10.8.2.
My syntax was gcc -o <filename> <sourcefile> and that was fine. Now I see I have an executable and file <filename> tells me as such, but I'm not sure how to actually run it beside double clicking the icon, /lame. When I try running the executable by just typing I get command not found, but I thought it was executable...?
Thank you.
EDIT: I"m so stupid, it was just open <filename>
Unix will only run commands if they are available on the system path, as you can view by the $PATH variable
echo $PATH
Executables located in directories that are not on the path cannot be run unless you specify their full location. So in your case, assuming the executable is in the current directory you are working with, then you can execute it as such
./my-exec
Where my-exec is the name of your program.
To run an executable in mac
1). Move to the path of the file:
cd/PATH_OF_THE_FILE
2). Run the following command to set the file's executable bit using the chmod command:
chmod +x ./NAME_OF_THE_FILE
3). Run the following command to execute the file:
./NAME_OF_THE_FILE
Once you have run these commands, going ahead you just have to run command 3, while in the files path.

Cygwin not recognizing command

I downloaded a "directory".tar.gz, extracted and unzipped the file to obtain "directory".
The installation files for this directory, were to run the make command in cygwin, to compile and pull out the files of the directory, which were written in C.
I attempt to run a command in cygwin, pfunc, which is a command supposed to be available after compiling and performing make, but cygwin says command not found.
I'm completely new to unix and cygwin.
The problem is that pfunc, if it exists, is not on your path.
The first step is to see if pfunc actually exists and if so, find out where. find / -xdev -name pfunc will give you the location of all files named pfunc. Obviously, if pfunc doesn't exist, you have another problem on your hands.
Next, you'll want to add this path to your bashrc. You can do that with:
echo "export PATH=$PATH:<the/path/find/gave/you> >> ~/.bashrc
Finally, you need to update your path in the current shell with source ~/.bashrc
K, I figured it out, there was a problem with the implementation of the program on cygwin, and for some reason find -name ....etc couldn't find the file. However, I found the location and reset the path to find the .exe file. Now everything looks good! thanks again!

Resources