LXTerminal not finding guest scripts!

Non release banter
Post Reply
User avatar
Ed_P
Contributor
Contributor
Posts: 3163
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

LXTerminal not finding guest scripts!

Post#1 by Ed_P » 26 Mar 2014, 21:16

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
Ed

User avatar
fanthom
Site Admin
Site Admin
Posts: 4566
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: LXTerminal not finding guest scripts!

Post#2 by fanthom » 26 Mar 2014, 21:31

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
Please add [Solved] to your thread title if the solution was found.

User avatar
Ed_P
Contributor
Contributor
Posts: 3163
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: LXTerminal not finding guest scripts!

Post#3 by Ed_P » 27 Mar 2014, 07:00

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.
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 3163
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: LXTerminal not finding guest scripts!

Post#4 by Ed_P » 04 Jul 2014, 04:40

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.
Last edited by Ed_P on 06 May 2016, 21:24, edited 1 time in total.
Ed

User avatar
brokenman
Site Admin
Site Admin
Posts: 5460
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: LXTerminal not finding guest scripts!

Post#5 by brokenman » 04 Jul 2014, 14:10

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
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
Ed_P
Contributor
Contributor
Posts: 3163
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: LXTerminal not finding guest scripts!

Post#6 by Ed_P » 04 Jul 2014, 14:50

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:
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 3163
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: LXTerminal not finding guest scripts!

Post#7 by Ed_P » 04 Jul 2014, 22:47

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
Ed

Post Reply