Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #174181 > unrolled thread

Trivial script will NOT execute

Started byRichard Owlett <rowlett@cloud85.net>
First post2016-11-05 02:00 +0100
Last post2016-11-05 02:40 +0100
Articles 10 — 7 participants

Back to article view | Back to linux.debian.user


Contents

  Trivial script will NOT execute Richard Owlett <rowlett@cloud85.net> - 2016-11-05 02:00 +0100
    Re: Trivial script will NOT execute "John L. Ries" <jries@salford-systems.com> - 2016-11-05 02:10 +0100
      Re: Trivial script will NOT execute Richard Owlett <rowlett@cloud85.net> - 2016-11-05 02:40 +0100
        Re: Trivial script will NOT execute "John L. Ries" <jries@salford-systems.com> - 2016-11-05 04:30 +0100
        Re: Trivial script will NOT execute David Wright <deblis@lionunicorn.co.uk> - 2016-11-05 16:50 +0100
          Re: Trivial script will NOT execute Greg Wooledge <wooledg@eeg.ccf.org> - 2016-11-07 14:00 +0100
            Re: Trivial script will NOT execute David Wright <deblis@lionunicorn.co.uk> - 2016-11-07 14:50 +0100
    Re: Trivial script will NOT execute Christian Seiler <christian@iwakd.de> - 2016-11-05 02:20 +0100
      Re: Trivial script will NOT execute Ben Caradoc-Davies <ben@transient.nz> - 2016-11-05 04:00 +0100
    Re: Trivial script will NOT execute sunrise@mailbug.com - 2016-11-05 02:40 +0100

#174181 — Trivial script will NOT execute

FromRichard Owlett <rowlett@cloud85.net>
Date2016-11-05 02:00 +0100
SubjectTrivial script will NOT execute
Message-ID<szXuW-Ff-1@gated-at.bofh.it>
Today I've been having weird problems executing scripts.
As I have no valuable data on the partition containing Debian, I 
wiped it and did a fresh install of Debian Jessie (8.6.0) MATE 
desktop environment from a purchased set of DVDs. Earlier today I 
had had reason to create an *,iso of DVD1 of 13 using xorriso. 
The ISO had a MD5SUM matching the one at debian.org .

More than a half-century of trouble shooting *screams* 'operator 
error' ;[
But what????? [Caja reports the execute bit is set ;]

Cut-n-paste from MATE terminal:
root@full-jessier:~# #!/bin/bash -x
root@full-jessier:~# cd /media/root/myrepo
root@full-jessier:/media/root/myrepo# RCO
bash: RCO: command not found
root@full-jessier:/media/root/myrepo# ls
lost+found  new file  RCO  x2  xtract2 (copy)
root@full-jessier:/media/root/myrepo#


The content of RCO [with Linux line endings] is:

F='dvd8_'
N=0
E='.iso'
echo ""
while true
   do
     read -p "press Enter (Ctrl+C to exit)" dummyvar
     let N=N+1
     FILENAME=$F$N$E
     echo $FILENAME
     echo ""
     echo "*********************"
  done


Assistance appreciated.

[toc] | [next] | [standalone]


#174182

From"John L. Ries" <jries@salford-systems.com>
Date2016-11-05 02:10 +0100
Message-ID<szXEB-Xj-1@gated-at.bofh.it>
In reply to#174181
Any chance the current directory is not in your path?

--------------------------|
John L. Ries              |
Salford Systems           |
Phone: (619)543-8880 x107 |
or     (435)867-8885      |
--------------------------|

On 11/4/16 6:51 PM, Richard Owlett wrote:
> Today I've been having weird problems executing scripts.
> As I have no valuable data on the partition containing Debian, I wiped
> it and did a fresh install of Debian Jessie (8.6.0) MATE desktop
> environment from a purchased set of DVDs. Earlier today I had had
> reason to create an *,iso of DVD1 of 13 using xorriso. The ISO had a
> MD5SUM matching the one at debian.org .
>
> More than a half-century of trouble shooting *screams* 'operator
> error' ;[
> But what????? [Caja reports the execute bit is set ;]
>
> Cut-n-paste from MATE terminal:
> root@full-jessier:~# #!/bin/bash -x
> root@full-jessier:~# cd /media/root/myrepo
> root@full-jessier:/media/root/myrepo# RCO
> bash: RCO: command not found
> root@full-jessier:/media/root/myrepo# ls
> lost+found  new file  RCO  x2  xtract2 (copy)
> root@full-jessier:/media/root/myrepo#
>
>
> The content of RCO [with Linux line endings] is:
>
> F='dvd8_'
> N=0
> E='.iso'
> echo ""
> while true
>   do
>     read -p "press Enter (Ctrl+C to exit)" dummyvar
>     let N=N+1
>     FILENAME=$F$N$E
>     echo $FILENAME
>     echo ""
>     echo "*********************"
>  done
>
>
> Assistance appreciated.
>
>
>

[toc] | [prev] | [next] | [standalone]


#174185

FromRichard Owlett <rowlett@cloud85.net>
Date2016-11-05 02:40 +0100
Message-ID<szY7D-16t-17@gated-at.bofh.it>
In reply to#174182
On 11/4/2016 7:54 PM, John L. Ries wrote:
> Any chance the current directory is not in your path?
>

That's not a mere 'scary' thought,
it is a *TERRIFYING* thought :<

"Why?" you may ask.
" 'cause it implies an intrinsic failure of *nix documentation."

As a computer *USER* I predate CPM80.
I've always assumed that 'cd xyz' implicitly implied that xyz now 
implicitly implied that {xyz} was not only the "Current Working 
Directory" but in default path.

After my post, but before your reply, I had tried
   echo $PATH
result was not encouraging :<

I now suspect not only "operator error" but "operator ignorance" ;<
What should I "be reading"/"have read" ?
TIA

P.S. a few hours ago a similar script had executed as I naively 
expected ;/



>
> On 11/4/16 6:51 PM, Richard Owlett wrote:
>> Today I've been having weird problems executing scripts.
>> As I have no valuable data on the partition containing Debian, I wiped
>> it and did a fresh install of Debian Jessie (8.6.0) MATE desktop
>> environment from a purchased set of DVDs. Earlier today I had had
>> reason to create an *,iso of DVD1 of 13 using xorriso. The ISO had a
>> MD5SUM matching the one at debian.org .
>>
>> More than a half-century of trouble shooting *screams* 'operator
>> error' ;[
>> But what????? [Caja reports the execute bit is set ;]
>>
>> Cut-n-paste from MATE terminal:
>> root@full-jessier:~# #!/bin/bash -x
>> root@full-jessier:~# cd /media/root/myrepo
>> root@full-jessier:/media/root/myrepo# RCO
>> bash: RCO: command not found
>> root@full-jessier:/media/root/myrepo# ls
>> lost+found  new file  RCO  x2  xtract2 (copy)
>> root@full-jessier:/media/root/myrepo#
>>
>>
>> The content of RCO [with Linux line endings] is:
>>
>> F='dvd8_'
>> N=0
>> E='.iso'
>> echo ""
>> while true
>>    do
>>      read -p "press Enter (Ctrl+C to exit)" dummyvar
>>      let N=N+1
>>      FILENAME=$F$N$E
>>      echo $FILENAME
>>      echo ""
>>      echo "*********************"
>>   done
>>
>>
>> Assistance appreciated.
>>
>>
>>
>
>

[toc] | [prev] | [next] | [standalone]


#174188

From"John L. Ries" <jries@salford-systems.com>
Date2016-11-05 04:30 +0100
Message-ID<szZQ5-2tA-1@gated-at.bofh.it>
In reply to#174185
I actually found out about the path issue as a brand new UNIX user
(OSF/1, to be exact) in 1994 (I was a die hard DOS user before that).
To this day, I have "." in my path, but last and only on my personal
account (never as root).

--------------------------|
John L. Ries              |
Salford Systems           |
Phone: (619)543-8880 x107 |
or     (435)867-8885      |
--------------------------|


On Friday 2016-11-04 19:37, Richard Owlett wrote:

>Date: Fri, 4 Nov 2016 19:37:53
>From: Richard Owlett <rowlett@cloud85.net>
>To: debian-user@lists.debian.org
>Subject: Re: Trivial script will NOT execute
>Resent-Date: Sat, 5 Nov 2016 01:38:19 +0000
>Resent-From: <debian-user@lists.debian.org>
>
> On 11/4/2016 7:54 PM, John L. Ries wrote:
>> Any chance the current directory is not in your path?
>>
>
> That's not a mere 'scary' thought,
> it is a *TERRIFYING* thought :<
>
> "Why?" you may ask.
> " 'cause it implies an intrinsic failure of *nix documentation."
>
> As a computer *USER* I predate CPM80.
> I've always assumed that 'cd xyz' implicitly implied that xyz now implicitly
> implied that {xyz} was not only the "Current Working Directory" but in default
> path.
>
> After my post, but before your reply, I had tried
>  echo $PATH
> result was not encouraging :<
>
> I now suspect not only "operator error" but "operator ignorance" ;<
> What should I "be reading"/"have read" ?
> TIA
>
> P.S. a few hours ago a similar script had executed as I naively expected ;/
>
>
>
>>
>> On 11/4/16 6:51 PM, Richard Owlett wrote:
>>> Today I've been having weird problems executing scripts.
>>> As I have no valuable data on the partition containing Debian, I wiped
>>> it and did a fresh install of Debian Jessie (8.6.0) MATE desktop
>>> environment from a purchased set of DVDs. Earlier today I had had
>>> reason to create an *,iso of DVD1 of 13 using xorriso. The ISO had a
>>> MD5SUM matching the one at debian.org .
>>>
>>> More than a half-century of trouble shooting *screams* 'operator
>>> error' ;[
>>> But what????? [Caja reports the execute bit is set ;]
>>>
>>> Cut-n-paste from MATE terminal:
>>> root@full-jessier:~# #!/bin/bash -x
>>> root@full-jessier:~# cd /media/root/myrepo
>>> root@full-jessier:/media/root/myrepo# RCO
>>> bash: RCO: command not found
>>> root@full-jessier:/media/root/myrepo# ls
>>> lost+found  new file  RCO  x2  xtract2 (copy)
>>> root@full-jessier:/media/root/myrepo#
>>>
>>>
>>> The content of RCO [with Linux line endings] is:
>>>
>>> F='dvd8_'
>>> N=0
>>> E='.iso'
>>> echo ""
>>> while true
>>>   do
>>>     read -p "press Enter (Ctrl+C to exit)" dummyvar
>>>     let N=N+1
>>>     FILENAME=$F$N$E
>>>     echo $FILENAME
>>>     echo ""
>>>     echo "*********************"
>>>  done
>>>
>>>
>>> Assistance appreciated.
>>>
>>>
>>>
>>
>>
>
>

[toc] | [prev] | [next] | [standalone]


#174194

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2016-11-05 16:50 +0100
Message-ID<sAbod-1dk-5@gated-at.bofh.it>
In reply to#174185
On Fri 04 Nov 2016 at 20:37:53 (-0500), Richard Owlett wrote:
> On 11/4/2016 7:54 PM, John L. Ries wrote:
> >Any chance the current directory is not in your path?
> >
> 
> That's not a mere 'scary' thought,
> it is a *TERRIFYING* thought :<

Steady on...

> "Why?" you may ask.
> " 'cause it implies an intrinsic failure of *nix documentation."

Or of someone to read it.

> What should I "be reading"/"have read" ?

man bash

(Put whatever shell you use.)

Anyone changing their $PATH should make themselves aware of the danger
of adding . explicitly, or even implicitly by, say, thinking that : is
a delimiter rather than a separator, or by screwing up a parameter
substitution and ending up with :: anywhere in the $PATH.

The current working directory is included here three times—at the
beginning, middle and end.

:/usr/bin::/bin:.

One other point. I see you use spaces in your filenames. Regardless of
this, you should quote your strings in such as FILENAME=$F$N$E

Cheers,
David.

[toc] | [prev] | [next] | [standalone]


#174286

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2016-11-07 14:00 +0100
Message-ID<sARGT-3e5-37@gated-at.bofh.it>
In reply to#174194
On Sat, Nov 05, 2016 at 10:42:46AM -0500, David Wright wrote:
> The current working directory is included here three times???at the
> beginning, middle and end.
> 
> :/usr/bin::/bin:.

Including the current directory in one's PATH (either by using "."
explicitly, or by using an empty string) is considered a bad practice.
It opens you up to certain exploits by malicious users.

The classic example is that a malicious user puts a program named "sl"
in the /tmp directory, and waits for someone (preferably root) to
change directory to /tmp and then mistype "ls" as "sl".  This runs the
malicious user's program with the other user's privileges.

Thus, it's strongly recommended that you do *not* put the current
working directory into PATH.  If you need to execute a program in
the current directory, you can invoke it with a leading ./

./myscript

This bypasses the PATH lookup (because the command name contains a
slash character).  The leading "." is simply a directory name, not
anything magic to the shell.

> One other point. I see you use spaces in your filenames. Regardless of
> this, you should quote your strings in such as FILENAME=$F$N$E

In a simple assignment like that, you don't need to quote.  Word
splitting and pathname expansion are not performed, for legacy
reasons.  However, quoting doesn't hurt.

http://mywiki.wooledge.org/Quotes

[toc] | [prev] | [next] | [standalone]


#174291

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2016-11-07 14:50 +0100
Message-ID<sAStb-3NV-15@gated-at.bofh.it>
In reply to#174286
On Mon 07 Nov 2016 at 07:59:25 (-0500), Greg Wooledge wrote:
> On Sat, Nov 05, 2016 at 10:42:46AM -0500, David Wright wrote:
> > The current working directory is included here three times???at the
> > beginning, middle and end.
> > 
> > :/usr/bin::/bin:.
> 
> Including the current directory in one's PATH (either by using "."
> explicitly, or by using an empty string) is considered a bad practice.
> It opens you up to certain exploits by malicious users.

Yes, thanks for reinforcing the point I made in my previous paragraph.
While many people are aware that inserting . in ones PATH is bad
practice, far fewer seem to be aware that an extra : is just as bad
because of the same effect.

> > One other point. I see you use spaces in your filenames. Regardless of
> > this, you should quote your strings in such as FILENAME=$F$N$E
> 
> In a simple assignment like that, you don't need to quote.  Word
> splitting and pathname expansion are not performed, for legacy
> reasons.  However, quoting doesn't hurt.
> 
> http://mywiki.wooledge.org/Quotes

Let us hope that the OP (to whow my comment was personally directed)
reads your pages and the many excellent ones that accompany it.
Your rule of thumb might be a good practice for the OP to follow:

"The basic rule of thumb is that you should double-quote every
expansion. [...] When in doubt, quote it."

I think that '''
    That's not a mere 'scary' thought, it is a *TERRIFYING* thought :<
    "Why?" you may ask. " 'cause it implies an intrinsic failure of *nix documentation."
''' is a good indication of doubt on the part of the OP.

Cheers,
David.

[toc] | [prev] | [next] | [standalone]


#174183

FromChristian Seiler <christian@iwakd.de>
Date2016-11-05 02:20 +0100
Message-ID<szXOh-10r-1@gated-at.bofh.it>
In reply to#174181
On 11/05/2016 01:51 AM, Richard Owlett wrote:
> Today I've been having weird problems executing scripts.
> As I have no valuable data on the partition containing Debian, I
> wiped it and did a fresh install of Debian Jessie (8.6.0) MATE
> desktop environment from a purchased set of DVDs. Earlier today I had
> had reason to create an *,iso of DVD1 of 13 using xorriso. The ISO
> had a MD5SUM matching the one at debian.org .
> 
> More than a half-century of trouble shooting *screams* 'operator error' ;[
> But what????? [Caja reports the execute bit is set ;]
> 
> Cut-n-paste from MATE terminal:
> root@full-jessier:~# #!/bin/bash -x
> root@full-jessier:~# cd /media/root/myrepo
> root@full-jessier:/media/root/myrepo# RCO
> bash: RCO: command not found

By default for security reasons the current directory is not in the
PATH environment variable on Linux. Perhaps in your previous install
you had manually added it to your environment, but in a fresh
installation with an empty home directory (or at the very least
without restoring dotfiles in your home directory) it will not be
present.

You can add it to PATH via:

export PATH=$PATH:.

in the current shell. You can also add that line to your ~/.bashrc
to make that permanent. (Note that you appear to be running this as
root, so ~ means the home directory of the root user here, typically
/root.)

Please be aware of the security implications of this though; while
adding it to the end of PATH (as my line above does) is not quite as
bad as adding it in the front, this could lead you to potentially
running programs from untrusted sources. (Example scenario: you have
a command line open in a directory which contains an executable or a
script with the name of something you want to execute, you
accidentally removed the command a month ago during a system update;
in that case typing in that command will execute the binary/script
from the current directory - and if the current directory comes from
an untrusted source, because it's on an external pendrive that you
don't trust, for example, then it could lead you to executing
malicious code.)

Alternatively, what most people do is not add the current directory
to PATH explicitly. Because there's another way to call a script or
binary from the current directory, by explicitly telling the shell
what you want - in this case by prepending './'. In your case, you
can do

./RC0

and that will execute the script "RC0" in the current directory. It
will also be explicit that you are executing something from the
current directory and not a system command - which is why I prefer
to do it this way instead of tinkering with PATH here.

As a side note: your script RC0 doesn't appear to start with a
shebang line. In that case the script will be executed via /bin/sh,
so it will work regardless, but I would suggest to make that
explicit by having the script start with #!/bin/sh. (Or #!/bin/bash
if you need bash features in the script.)

Regards,
Christian

[toc] | [prev] | [next] | [standalone]


#174187

FromBen Caradoc-Davies <ben@transient.nz>
Date2016-11-05 04:00 +0100
Message-ID<szZn8-1Xp-3@gated-at.bofh.it>
In reply to#174183
On 05/11/16 14:19, Christian Seiler wrote:
> By default for security reasons the current directory is not in the
> PATH environment variable on Linux.

I will never again permit "." in my $PATH since the day I tried to run 
killall (meaning /usr/bin/killall) while in /etc/init.d on a production 
Red Hat server. Unbeknownst to me, a "helpful" fellow admin had put "." 
at the front of root's $PATH, so /etc/init.d/killall ran (part of the 
shutdown process) and left the system in an unusable hung state, 
requiring me to obtain physical access, perform a hard reset, and go 
into hiding.

+1 for ./scriptname or scripts installed in well-defined bin directories 
that have a well-considered order on the $PATH.

Kind regards,

-- 
Ben Caradoc-Davies <ben@transient.nz>
Director
Transient Software Limited <http://transient.nz/>
New Zealand

[toc] | [prev] | [next] | [standalone]


#174184

Fromsunrise@mailbug.com
Date2016-11-05 02:40 +0100
Message-ID<szY7D-16t-5@gated-at.bofh.it>
In reply to#174181


On Fri, 4 Nov 2016 19:51:50 -0500
Richard Owlett <rowlett@cloud85.net> wrote:

>Today I've been having weird problems executing scripts.
>As I have no valuable data on the partition containing Debian, I 
>wiped it and did a fresh install of Debian Jessie (8.6.0) MATE 
>desktop environment from a purchased set of DVDs. Earlier today I 
>had had reason to create an *,iso of DVD1 of 13 using xorriso. 
>The ISO had a MD5SUM matching the one at debian.org .
>
>More than a half-century of trouble shooting *screams* 'operator 
>error' ;[
>But what????? [Caja reports the execute bit is set ;]
>
>Cut-n-paste from MATE terminal:
>root@full-jessier:~# #!/bin/bash -x
>root@full-jessier:~# cd /media/root/myrepo
>root@full-jessier:/media/root/myrepo# RCO

Try specifying the full path name to the script, as in:

root@full-jessier:~# /media/root/myrepo/RCO

or

root@full-jessier:~# cd /media/root/myrepo
root@full-jessier:/media/root/myrepo# ./RCO


>bash: RCO: command not found
>root@full-jessier:/media/root/myrepo# ls
>lost+found  new file  RCO  x2  xtract2 (copy)
>root@full-jessier:/media/root/myrepo#
>
>
>The content of RCO [with Linux line endings] is:
>
>F='dvd8_'
>N=0
>E='.iso'
>echo ""
>while true
>   do
>     read -p "press Enter (Ctrl+C to exit)" dummyvar
>     let N=N+1
>     FILENAME=$F$N$E
>     echo $FILENAME
>     echo ""
>     echo "*********************"
>  done
>
>
>Assistance appreciated.
>
>


Thanks,
Jason

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web