executable file must be placed in either the current working directory or somewhere in the command path - command-line

I'm installing a command line program called plink that recommends this:
The PLINK executable file should be placed in either the current
working directory or somewhere in the command path. This means that
typing "plink" or "./plink" at the command line prompt will run PLINK,
no matter which current directory you happen to be in. PLINK is a
command line program -- clicking on an icon with the mouse will get
you nowhere.
I have the PLINK executable file. What should I do next?

Run 'chmod +x plink' to grant the file execution rights.

Related

Matlab doesn't recognize user environmental variable

I installed an application named lqns in the path: /home/robb/Research/dist/lqns-6.2/lqns (lqns is a folder containing the executable lqns). I want the program to be executed in command line simply calling lqns in the shell, I solved this adding to the file ~/.bashrc the line:
export PATH=$PATH:/home/robb/Research/dist/lqns-6.2/lqns
And it works with no issue. I am now trying to execute this program inside a Matlab script, running:
[status, ~] = system("lqns " + filename, '-echo');
Where filename is the path of an input file. I get the error message:
/bin/bash: line 1: lqns: command not found
Running the exact same command with the shell I get no error: the program runs with no problem generating the relative output.
Running getenv('PATH'); in Matlab and printenv PATH on my OS shell I indeed get two different results: Matlab does't have the path to lqns. I even tried editing manually the files /etc/environment, /etc/bash.bashrc and /root/.bashrc, with no result. How can I solve this issue?
you need to launch matlab by typing matlab in a terminal, not by double clicking on its shortcut from your desktop. (or even typing ./matlab in a terminal from your desktop)
it's up to the operating system to determine what double clicking does, and it's not guaranteed to execute most of your shell initialization scripts (or even launch it from the correct shell to begin with).
more info at Why are environment variables not resolved when double-clicking .desktop file?

How to open a tab/pane in the same directory in Windows Terminal with Fish shell

Microsoft has a guide how to do that for other shells such as bash and zsh but not for fish shell.
https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory
open your fish config file located at ~/.config/fish/config.fish and add to it the following function:
function storePathForWindowsTerminal --on-variable PWD
if test -n "$WT_SESSION"
printf "\e]9;9;%s\e\\" (wslpath -w "$PWD")
end
end
Explanation:
This function is a hook that is called whenever current path is changed.
It will confirm current session is opened by Windows Terminal (By verifying environment variable $WT_SESSION exists), and will send Operating System Command (OSC 9;9;), with the Windows equivalent path (wslpath -w) of current path.
This sequence will let Windows Terminal know that the path was changed and when a new tab / pane will be created, Windows Terminal will use the changed path as current directory.

How to execute custom fish scripts in custom path folder

I'm having trouble executing a fish shell script I created. I added it to a custom path I added using fish_add_path. The folder appears just fine in $fish_user_paths and $PATH, and i've CHMOD +x the file, but when I type the name of the file, (which is pickc ath the moment), it can't find the command. How do I add fish scripts to the path and execute them like any other cli command (e.g. pickc)?
The content of the script is:
#!usr/bin/fish
colorpicker --short --one-shot --preview | sed -z 's/\n//g' | xclip -selection c
pkill picom
picom -b
I can execute the script just fine with the fish -c pickc command, but I can't execute with ./pickc, which gives me the error
Failed to execute process './pickc'. Reason: The file './pickc' does not exist or could not be executed.
I have doubly confirmed that the path in the $PATH and $fish_user_variable variable does lead to the folder containing the script.
Edit: I noticed that my paths were all really messed up somehow. The below answer does fix the issue of not being able to execute it, so thanks
You have mistyped your shebang. Switch
#!usr/bin/fish
to
#!/usr/bin/fish
or whatever path which fish shows.

cmd file that starts plink.exe from a nant script not working

I have a .cmd file that start plink.exe and runs several commands.
This works great if I open a command prompt and run the .cmd file.
It does not work when I call the .cmd file from an nant script.
Oh. the nant script is on a windows machine and the plink.exe is connecting to a linux machine.
Any ideas?
Is the NANT script running under the same user, when you manually run it? Make sure the user's have enough access rights.
Do you notice any error messages? Perhaps it is not founding the command executable i.e. plink.exe in the PATH environment variable.
You can put following in your .cmd file:
echo %PATH%
Compare what you get when you run directly on the prompt and run through nant script. Please also provide the plink command line you are using in the .cmd file.

How to run perl script from any where (any directory)

I have a perl script exist in the follwoing path (/home/Leen/Desktop/Tools/bin/tool.pl)
Every time I want to run this tool I go to the terminal
>
and then change the directory to
..../bin>
Then I run the perl by writing
..../bin> perl tool.pl file= whatever config= whatever
The problem is that I want to run this perl script without the need to go to the bin folder where it exist . so I can run perl script from any directory and as soon as I enter shell
I went to the etc/environment and I wrote the follwoing
export PERL5LIB=$PERL5LIB:/home/Leen/Desktop/Tools/bin
But when I go to terminal and write the follwoing straight ahead without going to bin folder where tool.pl exist
>perl tool.pl file=... config=...
it says the file "tool.pl" does not exist???
The first argument to the perl program is the path to an executable file. These calls are equivalent:
:~$ perl /home/Leen/Desktop/Tools/bin/tool.pl
:~$ perl ~/Desktop/Tools/bin/tool.pl
:~$ perl ./Desktop/Tools/bin/tool.pl
:~/Desktop/Tools/bin$ perl tool.pl
:~/Desktop/Tools/bin$ perl ./tool.pl
etc.
In the shell the tilde ~ expands to your home directory, and ./ symbolizes the current directory. On *nix shells (including the various terminal emulators on ubuntu), the command prompt ususally is $ in nomal mode, # as root user and seldom %. > Is a secondary command prompt, e.g. when continuing a multiline argument, unlike cmd.exe on Windows.
The PERL5LIB variable determines where Perl looks for modules, not for executable files.
You can set a script as executable via chmod +x FILENAME. You can then call the script without specifying the perl program:
:~/Desktop/Tools/bin$ ./tool.pl
You can modify the PATH variable to change where the shell looks for executables. The PATH usually contains /usr/bin/ and other directories. You can add a directory of your own via
PATH=$PATH:/home/Leen/Desktop/Tools/bin
Add your directory at the end of the PATHes, so you don't overrule other programs.
If you want to set this permanently, you can add this line to the file ~/.bashrc (only for your user and only for the bash shell).
Then you can call your script from anywhere, without a full path name:
:~/foo/bar$ tool.pl
You should consider using a more specific command name in this case, to prevent name clashes.