vashishatashu
vashishatashu

Reputation: 8172

Command Not Found In shell/bash scripts

I'm using ubuntu 14.10

I'm unable to find common commands in my script files which worked perfectly since a few days back.I have to give complete path for them now.

           /bin/mkdir "beta1"
           /usr/bin/npm install "$COMMAND"

which should be like :

           mkdir "beta1"
           npm install "$COMMAND"

I've even tried adding source ~/.profile in my script but nothing helps.

Upvotes: 0

Views: 779

Answers (2)

vashishatashu
vashishatashu

Reputation: 8172

Use of PATH as a variable name was the issue. I was overriding it at some point.

Upvotes: 0

David C. Rankin
David C. Rankin

Reputation: 84642

If the path you posted in the comments is a verbatim copy/paste of your path, your problem is you have embedded NON-ASCII characters in your path. This is most likely due to having edited your path using an editor in windows (or a non-text editor e.g. OpenOffice) that has substituted a non-standard character for a regular ASCII value. Looking at a hexdump of your PATH shows the problem:

$ hexdump -C -n 233 pathprob.sh
00000000  23 21 2f 62 69 6e 2f 62  61 73 68 0a 0a 50 41 54  |#!/bin/bash..PAT|
00000010  48 3d 2f 75 73 72 2f 6c  6f 63 61 6c 2f 73 62 69  |H=/usr/local/sbi|
00000020  6e 3a 2f 75 73 72 2f 6c  6f 63 61 6c 2f 62 69 6e  |n:/usr/local/bin|
00000030  3a 2f 75 73 72 2f 73 62  69 6e 3a 2f 75 73 72 2f  |:/usr/sbin:/usr/|
00000040  62 69 6e 3a 2f 73 62 69  6e 3a 2f 62 69 6e 3a 2f  |bin:/sbin:/bin:/|
00000050  75 73 72 2f 67 61 6d 65  73 3a 2f 75 73 72 2f 6c  |usr/games:/usr/l|
00000060  6f 63 e2 80 8c e2 80 8b  61 6c 2f 67 61 6d 65 73  |oc......al/games|
00000070  3a 2f 75 73 72 2f 73 62  69 6e 2f 6e 6f 64 65 3a  |:/usr/sbin/node:|
00000080  2f 75 73 72 2f 6c 69 62  2f 6a 76 6d 2f 6a 61 76  |/usr/lib/jvm/jav|
00000090  61 2d 37 2d 6f 72 61 63  6c 65 2f 62 69 6e 3a 2f  |a-7-oracle/bin:/|
000000a0  75 73 72 2f 6c 69 62 2f  6a 76 6d 2f 6a 61 76 61  |usr/lib/jvm/java|
000000b0  2d 37 2d 6f 72 61 63 6c  65 e2 80 8c e2 80 8b 2f  |-7-oracle....../|
000000c0  64 62 2f 62 69 6e 3a 2f  75 73 72 2f 6c 69 62 2f  |db/bin:/usr/lib/|
000000d0  6a 76 6d 2f 6a 61 76 61  2d 37 2d 6f 72 61 63 6c  |jvm/java-7-oracl|
000000e0  65 2f 6a 72 65 2f 62 69  6e                       |e/jre/bin|
000000e9

Notice how usr/loc......al/games appears. There is a similar problem with java-7-oracle....... This effectively corrupts your PATH variable. The corrupting characters are the same in both places e2 80 8c e2 80 8b. They represent a e2 80 8c a Unicode ⁌ and e2 80 8b a Unicode ⁋.

The soluton -- copy your path to a text editor. Delete/replace local/ with a new retyped local/ and do the same thing for /usr/lib/jvm/java-7-oracle/db/bin

Upvotes: 2

Related Questions