When I enter this command:
./vw -d click.train.vw -f click.model.vw --loss_function logistic
on cygwin I got this error:
-bash: ./vw: No such file or directory
I actually want to implement "PREDICTING CTR WITH ONLINE MACHINE LEARNING" website link for reference :
http://mlwave.com/predicting-click-through-rates-with-online-machine-learning/
Any help would be appreciated.
Answer based on common mistakes.
Execution by inexact name
Filename with blanks
Suppose you write ls in the command line and obtain the following:
$ ls
anyfile command
Then, you call your command with ./command and get the following:
$ ./command
bash: ./command: No such file or directory
Here you can think ls is wrong, but the actuality is that you can't easily recognize if a filename have, for example, leading or trailing spaces:
$ ls -Q # -Q, --quote-name -> enclose entry names in double quotes
"anyfile" "command "
As you see, here my command has a trailing space:
$ ./"command " # it works
Filename with extension
A common mistake is to call the command by the name without the extension (if any).
Let's name the command: command.sh:
$ ./command # wrong
$ ./command.sh # OK
Wrong file path
If you call your command with the prefix ./, it needs to be in your current directory ($PWD). If it is not, you will get:
$ ./command # relative path -> same as "$PWD/command"
bash: ./command: No such file or directory
In that case, you can try the following:
Executing the command by its absolute path
$ /home/user/command # absolute path (example). It starts with a slash (/).
Let the shell locate the command
If you provide just the command name without slashes, bash searches in each directory of the $PATH variable, for an executable file named command.
$ command
You can do that search with the which command:
$ which command
/usr/bin/command
If the search fails, you'll get comething like:
$ which unexistent_command
which: no unexistent_command in (/usr/local/sbin:/usr/local/bin:/usr/bin)
Broken link
Now, suppose you write ls -Q in the command line and obtain the following:
$ ls -Q
"anyfile" "command"
This time, you can be 100% secure command exists but when you try to execute it:
$ ./command
bash: ./command: No such file or directory
Reason? bash complains command doesn't exist, but what doesn't exist is the file command is pointing to by a Symbolic link. e.g.:
$ ls -l
total 0
-rw-r--r-- 1 user users 0 Jan 14 02:12 anyfile
lrwxrwxrwx 1 user users 27 Jan 14 02:12 command -> /usr/bin/unexistent_command
$ ls /usr/bin/unexistent_command
ls: cannot access /usr/bin/unexistent_command: No such file or directory
Notice that the following surely throw different errors that the one you are getting...
Execution permission
To execute a file, it must have the x bit activated. With ls -l you can check the file permission.
$ ls -l command
-rw-r--r-- 1 user users 0 Jan 3 19:52 command
In this case (it doesn't have the x bit activated), you can give permission with chmod:
$ chmod +x command
$ ls -l command
-rwxr-xr-x 1 user users 0 Jan 3 19:52 command
Related
I'm new to shell and still practicing on it.
When I typed
ls /bin
The shell prints many files
'[' mousetweaks
aa-enabled mscompress
aa-exec msexpand
aa-features-abi mt
aconnect mt-gnu
..
But when I typed
ls -l /bin
I was expecting the same output file in long format, but it seems like the shell just gives me a soft link
lrwxrwxrwx 1 root root 7 Sept 5 15:22 /bin -> usr/bin
I can't figure out why.
The POSIX specification for ls says this:
-l(The letter ell.) Do not follow symbolic links named as operands unless the -H or -L options are specified. Write out in long format (see the STDOUT section). Disable the -C, -m, and -x options.
If you want to change the behavior, in addition to the two options specified above, you can also put a trailing slash after the name (i.e., /bin/ instead of /bin).
Expected behavior
List the documents in a directory using an environmental variable.
Steps to Reproduce
INPUT
$ export ICLOUD_D="~/Library/Mobile\ Documents/com~apple~CloudDocs/"
$ source ~/.zshrc
$ echo $ICLOUD_D
$ ls $ICLOUD_D
OUTPUT
$ ~/Library/Mobile\ Documents/com~apple~CloudDocs/
$ ls: ~/Library/Mobile\ Documents/com~apple~CloudDocs/: No such file or directory
Current behavior
Shell gives me a: No such file or directory error.
Steps Performed Thus Far to Fix
If I were to simply cut and paste the file path with the command ls then I'm able to list the files as expected.
I've also tried to put quotes around the environmental variable as well.
$ ls "$ICLOUD_D"
System information
- OS: MacOS v 10.15
- Shell: zsh
Do not put quotes around the environmental variable
INPUT
$ export ICLOUD_D=~/Library/Mobile\ Documents/com~apple~CloudDocs/
$ source ~/.zshrc
$ echo $ICLOUD_D
$ ls $ICLOUD_D
OUTPUT
$ ~/Library/Mobile\ Documents/com~apple~CloudDocs/
$ afile
$ bfile
$ ...
I do not know why I am getting these error messages from the shell or where ever they are coming from?
I've simplified a make file. Here is the make file simple.mk
# simple trial makefile
$(warning Making where CURDIR is $(CURDIR))
$(warning $(shell ls -ld "$(CURDIR)" ) )
$(shell "ls -l $(CURDIR)" )
$(shell "\ls -l /home/me/BitHoist/run/objects" )
I run it.
me $ make -f simple.mk
simple.mk:2: Making where CURDIR is /home/me/BitHoist/source
simple.mk:3: drwxrwxr-x. 2 me me 4096 Apr 27 18:37 /home/me/BitHoist/source
/bin/sh: ls -l /home/me/BitHoist/source: No such file or directory
/bin/sh: \ls -l /home/me/BitHoist/run/objects: No such file or directory
make: *** No targets. Stop.
me $
I figured out one solution, enclose in $(warning )
I do not know why I am getting these error messages?
/bin/sh: ls -l /home/me/BitHoist/source: No such file or directory
/bin/sh: \ls -l /home/me/BitHoist/run/objects: No such file or directory
Seems to be an error message from sh.
Robert
Running $(shell "ls -l $(CURDIR)" ) is like typing "ls -l /home/me/BitHoist/source" to the shell prompt (including quotes).
Try that and you'll see you'll get the same error you get from the makefile. Make passes those quotes along to the shell verbatim, so the shell is trying to run a program literally named ls -l /home/me/BitHoist/source, which is obviously not a real program name. Hence the error.
I've copied a script from the unifi documentation
#!/bin/sh
## define required variables
username=admin
password=admin
baseurl=https://localhost:8443
## include the API library
. unifi_sh_api
unifi_login
# unifi_authorize_guest <mac> <minutes> [up=kbps] [down=kbps] [bytes=MB]
unifi_authorize_guest $1 $2
unifi_logout
This is the script and this is the file structure:
foo#site:/home/foo# ls
unifi.sh unifi_sh_api
This is what I get when I try to execute the file. What can cause this? The file is obviously in the right folder.
foo#site:/home/foo# sh unifi.sh
unifi.sh: 9: .: unifi_sh_api: not found
You are invoking bash as /bin/sh which puts bash into sh-compatibility mode. The POSIX standard says that:
If file does not contain a slash, the shell shall use the search path specified by PATH to find the directory containing file.
Which means that the current directory will not be searched unless it is part of $PATH:
$ /bin/sh -c '. test.sh'
/bin/sh: 1: .: t.sh: not found
$ /bin/sh -c 'PATH=".:$PATH"; . test.sh'
$
bash, however, seems to search the current directory:
$ /bin/bash -c '. test.sh'
$
I want to write something like
EXEC="sudo su -m root -c \"java Something\""
$EXEC &
But i get the following error:
Something": -c: line 0: unexpected EOF while looking for matching `"'
Something": -c: line 1: syntax error: unexpected end of file
If I write the command on the command line it executes. If I have it stored in a variable and trying to extrapolate it - it does not. Why?
Try this:
exec="ls -l \"/a b c\""
$exec
You will see something like:
ls: cannot access "/a: No such file or directory
ls: cannot access b: No such file or directory
ls: cannot access c": No such file or directory
Which shows exactly where the problem is - that is - expansion of variable is done after word splitting.
To make it work, you can use eval:
=$ eval "$exec"
ls: cannot access /a b c: No such file or directory
or even:
=$ sh -c "$exec"
Or better yet, don't make such commands to run. Not sure what is the purpose of it, but think about avoiding building full command lines in variables.