Page 1 of 1

LXTerminal not finding guest scripts!

Posted: 26 Mar 2014, 21:16
by Ed_P
With 2.1 when I opened a lxterminal window and entered my logrotate.sh script name it would execute. With 3.0 doing that results in a bash: logrotate.sh: command not found error.

logrotate.sh

Code: Select all

#!/bin/sh

if [ `whoami` != "root" ]; then
  ktsuss "$0"
  exit
fi

ls -al /var/log
logrotate /etc/logrotate.conf
ls -al /var/log

read
If I put in the full path it works.

Code: Select all

guest@porteus:~$ logrotate.sh
bash: logrotate.sh: command not found
guest@porteus:~$ /home/guest/logrotate.sh
total 1156
:
:
etc

Re: LXTerminal not finding guest scripts!

Posted: 26 Mar 2014, 21:31
by fanthom
run 'echo $PATH' and move your script to one of displayed folders (it had to be the case for 2.1) or launch it as './logrotate.sh'

lecture for you:
http://www.linfo.org/path_env_var.html

Re: LXTerminal not finding guest scripts!

Posted: 27 Mar 2014, 07:00
by Ed_P
Thanks for responding fanthom.

Razor 2.1 / 3.0

Code: Select all

guest@porteus:~$ echo 2.1
2.1
guest@porteus:~$ echo $PATH
/usr/lib64/razor-xdg-tools:/usr/local/bin:/usr/bin:/bin:/usr/games:/opt/porteus-scripts:/usr/lib64/java/jre/bin:/usr/lib64/qt/bin:.:/usr/lib64/java/jre/bin:/usr/lib64/qt/bin:/usr/lib64/java/jre/bin:/usr/lib64/qt/bin
guest@porteus:~$ logrotate.sh
total 2128
drwxr-xr-x 35 root root     320 Mar 27 02:36 .
drwxr-xr-x 36 root root     160 Mar 27 02:35 ..
:
:

Code: Select all

guest@porteus:~$ echo 3.0
3.0
guest@porteus:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/games:/opt/porteus-scripts:/usr/lib64/java/jre/bin:/usr/lib64/qt/bin:/usr/lib64/java/jre/bin:/usr/lib64/qt/bin:/usr/lib64/java/jre/bin:/usr/lib64/qt/bin
guest@porteus:~$ logrotate.sh
bash: logrotate.sh: command not found
The paths are different and neither contains /home/guest but the script's name in one works and in the other isn't found.

The ./logrotate.sh option does work with 3.0.

BTW The PATH concept has been in DOS for years also.

Re: LXTerminal not finding guest scripts!

Posted: 04 Jul 2014, 04:40
by Ed_P
A solution. :good:

Code: Select all

#!/bin/sh
# http://forum.porteus.org/viewtopic.php?f=81&t=3627&p=25998#p25998 
PATH=$PATH:.
#exit
echo "export PATH=$PATH:." > /etc/profile.d/add-z-dot-back-in-path.sh
chmod +x                     /etc/profile.d/add-z-dot-back-in-path.sh
As to why it changed, run: cat /etc/profile.d/z-dot-in-non-root-path.sh.

Re: LXTerminal not finding guest scripts!

Posted: 04 Jul 2014, 14:10
by brokenman
Huge security hole there. I like what the end of the comment in the script says.
Even better is just start programs in '.' with ./program, like most of us have been doing for years.
It only takes a split second to add ./ before a script name.

Having said that, if you are the only one using your machine and the security hole doesn't concern you. Just make this script executable and the . path will be permanent at every boot.
Executable scripts in this path (/etc/profile.d) are run at boot. If it is not executable it doesn't run.

Code: Select all

chmod +x /etc/profile.d/z-dot-in-non-root-path.sh

Re: LXTerminal not finding guest scripts!

Posted: 04 Jul 2014, 14:50
by Ed_P
brokenman wrote:It only takes a split second to add ./ before a script name.
Not the way I type. :D
Having said that, if you are the only one using your machine and the security hole doesn't concern you. Just make this script executable and the . path will be permanent at every boot.
Executable scripts in this path (/etc/profile.d) are run at boot. If it is not executable it doesn't run.

Code: Select all

chmod +x /etc/profile.d/z-dot-in-non-root-path.sh
I know, I read the comments in the code. I just feel more comfortable adding a module than changing a system module.

:friends:

Re: LXTerminal not finding guest scripts!

Posted: 04 Jul 2014, 22:47
by Ed_P
brokenman wrote:Huge security hole there. I like what the end of the comment in the script says.
Even better is just start programs in '.' with ./program, like most of us have been doing for years.
I don't understand the concern. Can't malware run something with a "./" in front also? Image