Page 1 of 1

bash not finding /home/guest/ scripts [Solved]

Posted: 05 May 2016, 19:22
by Ed_P
On my 486 machine I experienced this today.

Code: Select all

guest@porteus:~$ chmod +x test.sh
guest@porteus:~$ whoami
guest
guest@porteus:~$ test.sh
bash: test.sh: command not found
guest@porteus:~$ ls test.sh
test.sh*
guest@porteus:~$ cat test.sh
#!/bin/sh

if [ `whoami` != "root" ]
then
  echo guest
else
  echo root
fi
guest@porteus:~$ /home/guest/test.sh
guest
guest@porteus:~$ 
test.sh doesn't work but /home/guest/test.sh does.

If I specify any script in /home/guest/ bash no longer finds it!! :shock: I have to include the /home/guest/ path before the script's names. I've never had to do that before.

How do I fix this?

Re: bash not finding /home/guest/ scripts

Posted: 05 May 2016, 19:51
by Bogomips

Code: Select all

export PATH+=:.
Perhaps?

Re: bash not finding /home/guest/ scripts

Posted: 05 May 2016, 21:01
by Ed_P
Thanks Bogomips. It works but doesn't survive a reboot with my save.dat file.


-update-

Well, maybe it did. But now I get this.

Code: Select all

guest@porteus:~$ test.sh
bash: test.sh: command not found
guest@porteus:~$ sh test.sh
guest
guest@porteus:~$ chmod +x test.sh
guest@porteus:~$ test.sh
bash: test.sh: command not found
guest@porteus:~$ sh test.sh
guest
guest@porteus:~$
Very strange situation. At least for me.


-update-

Using a backup save.dat.

Code: Select all

guest@porteus:~$ test.sh
bash: test.sh: command not found
guest@porteus:~$ sh test.sh
not guest
guest@porteus:~$ /home/guest/test.sh
not guest
guest@porteus:~$ chmod +x test.sh
guest@porteus:~$ test.sh
bash: test.sh: command not found
guest@porteus:~$ 

Re: bash not finding /home/guest/ scripts

Posted: 05 May 2016, 22:49
by Bogomips
Try appending it here:

Code: Select all

guest@porteus:~$ cat .bashrc
# Setup color scheme for list call <brokenman>
alias ll='/bin/ls --color=auto -lF'
alias la='/bin/ls --color=auto -axF'
alias ls='/bin/ls --color=auto -xF'

# Append any additional sh scripts found in /etc/profile.d/:
for y in /etc/profile.d/*.sh ; do [ -x $y ] && . $y; done
unset y

# Setup shell prompt for guest <wread and fanthom>
PS1='\[\033[01;36m\]\u@\h:\[\033[01;32m\]\w\$\[\033[00m\] '
PS2='> '

Re: bash not finding /home/guest/ scripts

Posted: 06 May 2016, 00:38
by Ed_P
My file.

Code: Select all

guest@porteus:~$ cat .bashrc
# Setup color scheme for list call <brokenman>
alias ll='/bin/ls --color=auto -lF'
alias la='/bin/ls --color=auto -axF'
alias ls='/bin/ls --color=auto -xF'

# Append any additional sh scripts found in /etc/profile.d/:
for y in /etc/profile.d/*.sh ; do [ -x $y ] && . $y; done
unset y

# Setup shell prompt for guest <wread and fanthom>
PS1='\[\033[01;36m\]\u@\h:\[\033[01;32m\]\w\$\[\033[00m\] '
PS2='> '
guest@porteus:~$ 
It appears to be the same as yours. And I suspect scripts in your /home/guest/ work normally.

Very strange situation. :%)

Re: bash not finding /home/guest/ scripts

Posted: 06 May 2016, 01:08
by Bogomips

Code: Select all

echo export PATH+=:.  >> .bashrc
Tried that?

Re: bash not finding /home/guest/ scripts

Posted: 06 May 2016, 01:33
by brokenman
And I suspect scripts in your /home/guest/ work normally.
/home/guest should never be a part of your $PATH. You will need to add is manually. You can put the file in /usr/bin /usr/local/bin (where all scripts should go) and it will run normally. Alternatively you can prefix the path with ./ if you are in the same directory.

E.g: ./script.sh
or call it with sh: sh script.sh

Re: bash not finding /home/guest/ scripts

Posted: 06 May 2016, 16:25
by Ed_P
brokenman wrote:Alternatively you can prefix the path with ./ if you are in the same directory.

E.g: ./script.sh
or call it with sh: sh script.sh
:oops: Good grief. :oops:

Yes, of course, ./ is what I forgot. :oops: http://forum.porteus.org/viewtopic.php?f=123&t=3265

Code: Select all

guest@porteus:~$ test.sh
bash: test.sh: command not found
guest@porteus:~$ ./test.sh
guest
guest@porteus:~$ 
Thanks, again. :(