Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

...Unix, MS-DOS, and Windows NT (also known as the Good, the Bad, and the Ugly). -- Matt Welsh


computers / alt.os.linux.mint / Re: script error

SubjectAuthor
* script errorpinnerite
+* Re: script errorBig Al
|`* Re: script errorpinnerite
| `* Re: script errorjeorge
|  `- Re: script errorpinnerite
`* Re: script errorjeorge
 `* Re: script errorjeorge
  `- Re: script errorpinnerite

1
script error

<20230814211642.c7d4831c69f1e57610a7f3e3@gmail.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=6651&group=alt.os.linux.mint#6651

  copy link   Newsgroups: alt.os.linux.mint
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: pinner...@gmail.com (pinnerite)
Newsgroups: alt.os.linux.mint
Subject: script error
Date: Mon, 14 Aug 2023 21:16:42 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <20230814211642.c7d4831c69f1e57610a7f3e3@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="b13ea0f60e029c3e4540956215f84b54";
logging-data="2594387"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182byMNp+xVGEO3x6zV+A6oiPqbIDV27iA="
Cancel-Lock: sha1:ZmiwITRlW6NP149Lc/CWRz5Uwvw=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
 by: pinnerite - Mon, 14 Aug 2023 20:16 UTC

These are the first 8 lines of a script.

#! /bin/sh
# Test Script
#

function disp {
echo "$1"
read -rsn1
}

This is what happens when I try to execute it:

$ sudo ./test.sh
[sudo] password for xxxx:
../test.sh: 5: function: not found

../test.sh: 7: read: Illegal option -s
../test.sh: 8: Syntax error: "}" unexpected

I cannot understand the first "function not found" error message, Why?

--
Linux Mint 21.1 kernel version 5.15.0-78-generic Cinnamon 5.6.8

Re: script error

<ube2in$2f714$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=6652&group=alt.os.linux.mint#6652

  copy link   Newsgroups: alt.os.linux.mint
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bea...@invalid.com (Big Al)
Newsgroups: alt.os.linux.mint
Subject: Re: script error
Date: Mon, 14 Aug 2023 16:24:55 -0400
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <ube2in$2f714$1@dont-email.me>
References: <20230814211642.c7d4831c69f1e57610a7f3e3@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 14 Aug 2023 20:24:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f8e541c767c201d34604c968874230b3";
logging-data="2595876"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Cetsp1NDlRQh1E+SS4NSCddTtilnaE5Q="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:i2pAaChuh9u7Dmm1GGcVgEImEo0=
Content-Language: en-US
In-Reply-To: <20230814211642.c7d4831c69f1e57610a7f3e3@gmail.com>
 by: Big Al - Mon, 14 Aug 2023 20:24 UTC

On 8/14/23 16:16, this is what pinnerite wrote:
> These are the first 8 lines of a script.
>
> #! /bin/sh
> # Test Script
> #
>
> function disp {
> echo "$1"
> read -rsn1
> }
>
> This is what happens when I try to execute it:
>
> $ sudo ./test.sh
> [sudo] password for xxxx:
> ./test.sh: 5: function: not found
>
> ./test.sh: 7: read: Illegal option -s
> ./test.sh: 8: Syntax error: "}" unexpected
>
> I cannot understand the first "function not found" error message, Why?
>
>
>
>
Is that a proper way to declare a function? Never seen one in bash shell script, not that it's no possible, just
haven't done it.
--
Linux Mint 21.1 Cinnamon 5.6.8
Al

Re: script error

<ube3ng$1qa0$1@nnrp.usenet.blueworldhosting.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=6653&group=alt.os.linux.mint#6653

  copy link   Newsgroups: alt.os.linux.mint
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nnrp.usenet.blueworldhosting.com!.POSTED!not-for-mail
From: some...@invalid.invalid (jeorge)
Newsgroups: alt.os.linux.mint
Subject: Re: script error
Date: Mon, 14 Aug 2023 14:44:32 -0600
Organization: Ministry of Madness
Message-ID: <ube3ng$1qa0$1@nnrp.usenet.blueworldhosting.com>
References: <20230814211642.c7d4831c69f1e57610a7f3e3@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 14 Aug 2023 20:44:32 -0000 (UTC)
Injection-Info: nnrp.usenet.blueworldhosting.com; posting-account="YKRG+wcUE3ZH5QknWLsQFQjWpafUZ9Hi6Jg7DGavMDA";
logging-data="59712"; mail-complaints-to="usenet@blueworldhosting.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:28Vj60STXrKV6ERCRRcSXhEtweA= sha256:roPqNUBIPbNs53J/oWPcm4Lfv4TMupnKqhTlLjnyrdY=
sha1:+pUzPVB3vnTHVtp2Mxs2ZzjU0N8= sha256:rDGUoscV/cb5hsrw0bFgVRW+KGWlQm77o1KNrnx9bS8=
Content-Language: en-US
In-Reply-To: <20230814211642.c7d4831c69f1e57610a7f3e3@gmail.com>
 by: jeorge - Mon, 14 Aug 2023 20:44 UTC

On 8/14/23 2:16 PM, pinnerite wrote:
> function disp {

Try "function disp() {"

Re: script error

<ube4dl$1qa0$2@nnrp.usenet.blueworldhosting.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=6654&group=alt.os.linux.mint#6654

  copy link   Newsgroups: alt.os.linux.mint
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nnrp.usenet.blueworldhosting.com!.POSTED!not-for-mail
From: some...@invalid.invalid (jeorge)
Newsgroups: alt.os.linux.mint
Subject: Re: script error
Date: Mon, 14 Aug 2023 14:56:21 -0600
Organization: Ministry of Madness
Message-ID: <ube4dl$1qa0$2@nnrp.usenet.blueworldhosting.com>
References: <20230814211642.c7d4831c69f1e57610a7f3e3@gmail.com>
<ube3ng$1qa0$1@nnrp.usenet.blueworldhosting.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 14 Aug 2023 20:56:22 -0000 (UTC)
Injection-Info: nnrp.usenet.blueworldhosting.com; posting-account="YKRG+wcUE3ZH5QknWLsQFQjWpafUZ9Hi6Jg7DGavMDA";
logging-data="59712"; mail-complaints-to="usenet@blueworldhosting.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:EFSWKhNqpu8fagIHOKoWL/psBOI= sha256:OwbYAv3/B5pWPG2a23Aq7RXf2ovcL/dmDi8ArJ0hhfw=
sha1:lj/WWT1swN9l/qCtltyqZqaJxC8= sha256:IJYmXZemwUw7VRwJyLP037gXViMlfL2557CI2189xIE=
Content-Language: en-US
In-Reply-To: <ube3ng$1qa0$1@nnrp.usenet.blueworldhosting.com>
 by: jeorge - Mon, 14 Aug 2023 20:56 UTC

On 8/14/23 2:44 PM, jeorge wrote:
> On 8/14/23 2:16 PM, pinnerite wrote:
>> function disp {
>
> Try "function disp() {"

Heh, meant "disp() {"

Been writing awk scripts and so the "function" part looked right...

Re: script error

<20230815145525.9f703fcff924ac7a05ba8ace@gmail.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=6655&group=alt.os.linux.mint#6655

  copy link   Newsgroups: alt.os.linux.mint
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: pinner...@gmail.com (pinnerite)
Newsgroups: alt.os.linux.mint
Subject: Re: script error
Date: Tue, 15 Aug 2023 14:55:25 +0100
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <20230815145525.9f703fcff924ac7a05ba8ace@gmail.com>
References: <20230814211642.c7d4831c69f1e57610a7f3e3@gmail.com>
<ube3ng$1qa0$1@nnrp.usenet.blueworldhosting.com>
<ube4dl$1qa0$2@nnrp.usenet.blueworldhosting.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="b3d87e94f4eacfe614a715676319a156";
logging-data="3000166"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+NAEH6SJ3pf7gp3juh9bQRc1oZQ74I8OA="
Cancel-Lock: sha1:50o0De8NTBh6Yp79QjAnrUKpeBs=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
 by: pinnerite - Tue, 15 Aug 2023 13:55 UTC

On Mon, 14 Aug 2023 14:56:21 -0600
jeorge <someone@invalid.invalid> wrote:

> On 8/14/23 2:44 PM, jeorge wrote:
> > On 8/14/23 2:16 PM, pinnerite wrote:
> >> function disp {
> >
> > Try "function disp() {"
>
> Heh, meant "disp() {"
>
> Been writing awk scripts and so the "function" part looked right...

Correct!

Take a house mark.

Thanks, Alan

--
Linux Mint 21.1 kernel version 5.15.0-78-generic Cinnamon 5.6.8
AMD Phenom II x4 955 CPU 16Gb Dram 2TB Barracuda

Re: script error

<20230816113021.5312f0c93bb1c0eccb999643@gmail.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=6659&group=alt.os.linux.mint#6659

  copy link   Newsgroups: alt.os.linux.mint
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: pinner...@gmail.com (pinnerite)
Newsgroups: alt.os.linux.mint
Subject: Re: script error
Date: Wed, 16 Aug 2023 11:30:21 +0100
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <20230816113021.5312f0c93bb1c0eccb999643@gmail.com>
References: <20230814211642.c7d4831c69f1e57610a7f3e3@gmail.com>
<ube2in$2f714$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="8833c7e49541f65896dbfaab44f28bd4";
logging-data="3439888"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dP912t319mB1lKWgZ/UECiEZVDk0bkSM="
Cancel-Lock: sha1:GuPtFw1vBuqfqdoO45MWAoR2EaY=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
 by: pinnerite - Wed, 16 Aug 2023 10:30 UTC

On Mon, 14 Aug 2023 16:24:55 -0400
Big Al <Bears@invalid.com> wrote:

> On 8/14/23 16:16, this is what pinnerite wrote:
> > These are the first 8 lines of a script.
> >
> > #! /bin/sh
> > # Test Script
> > #
> >
> > function disp {
> > echo "$1"
> > read -rsn1
> > }
> >
> > This is what happens when I try to execute it:
> >
> > $ sudo ./test.sh
> > [sudo] password for xxxx:
> > ./test.sh: 5: function: not found
> >
> > ./test.sh: 7: read: Illegal option -s
> > ./test.sh: 8: Syntax error: "}" unexpected
> >
> > I cannot understand the first "function not found" error message, Why?
> >
> >
> >
> >
> Is that a proper way to declare a function? Never seen one in bash shell script, not that it's no possible, just
> haven't done it.
> --
> Linux Mint 21.1 Cinnamon 5.6.8
> Al
>

I picked that up from:

https://linuxize.com/post/bash-functions/

and chose the reserved word "function" approach.
After changing to: disp() { ...} as suggested, i quickly got the whole script to run smoothly.

Thanks again to everyone.
Alan

--
Linux Mint 21.1 kernel version 5.15.0-79-generic Cinnamon 5.6.8
AMD Phenom II x4 955 CPU 16Gb Dram 2TB Barracuda

Re: script error

<ubiii8$1u73$1@nnrp.usenet.blueworldhosting.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=6660&group=alt.os.linux.mint#6660

  copy link   Newsgroups: alt.os.linux.mint
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nnrp.usenet.blueworldhosting.com!.POSTED!not-for-mail
From: some...@invalid.invalid (jeorge)
Newsgroups: alt.os.linux.mint
Subject: Re: script error
Date: Wed, 16 Aug 2023 07:22:16 -0600
Organization: Ministry of Madness
Message-ID: <ubiii8$1u73$1@nnrp.usenet.blueworldhosting.com>
References: <20230814211642.c7d4831c69f1e57610a7f3e3@gmail.com>
<ube2in$2f714$1@dont-email.me>
<20230816113021.5312f0c93bb1c0eccb999643@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 16 Aug 2023 13:22:16 -0000 (UTC)
Injection-Info: nnrp.usenet.blueworldhosting.com; posting-account="YKRG+wcUE3ZH5QknWLsQFQjWpafUZ9Hi6Jg7DGavMDA";
logging-data="63715"; mail-complaints-to="usenet@blueworldhosting.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:j21gPlDUaaoTtRx+eL5YLTHSbPM= sha256:MpWPPi1XHmkcbzOTW1HjKxVQAyZxOYokrSbdFZ4o6PA=
sha1:PrNjGHSQZrfbdrALeQHGBG4KNxE= sha256:K9/jDhBwKFlZgo72iPbCuSRgdZUNaupMJ4of5zz7Izw=
In-Reply-To: <20230816113021.5312f0c93bb1c0eccb999643@gmail.com>
Content-Language: en-US
 by: jeorge - Wed, 16 Aug 2023 13:22 UTC

On 8/16/23 4:30 AM, pinnerite wrote:
> I picked that up from:
>
> https://linuxize.com/post/bash-functions/
>
> and chose the reserved word "function" approach.
> After changing to: disp() { ...} as suggested, i quickly got the whole script to run smoothly.

FYI - you could have used the 'function fname {...}' form but you'd need
to change the "shabang" line to be '#!/bin/bash' ; using '#!/bin/sh'
calls dash(1), the bash(1) version of the traditional Bourne shell which
doesn't support the 'function' reserve word, aka a "bashism". Other
shells such as mksh(1) also support the 'function' reserve word form
(with optional '()' after the 'fname') but generally call it out as an
"ignored bashism".

If you find yourself writing more shell scripts you might add
"comp.unix.shell" to your newgroup subscriptions; I've learned quite a
bit following it.

Cheers,
jeorge

Re: script error

<20230816183650.53f341da31042ee6bdcfbc99@gmail.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=6661&group=alt.os.linux.mint#6661

  copy link   Newsgroups: alt.os.linux.mint
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: pinner...@gmail.com (pinnerite)
Newsgroups: alt.os.linux.mint
Subject: Re: script error
Date: Wed, 16 Aug 2023 18:36:50 +0100
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <20230816183650.53f341da31042ee6bdcfbc99@gmail.com>
References: <20230814211642.c7d4831c69f1e57610a7f3e3@gmail.com>
<ube2in$2f714$1@dont-email.me>
<20230816113021.5312f0c93bb1c0eccb999643@gmail.com>
<ubiii8$1u73$1@nnrp.usenet.blueworldhosting.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="8833c7e49541f65896dbfaab44f28bd4";
logging-data="3567152"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+K8NsuEWI70aGu+zoGbkx0qYWX0gh2eOo="
Cancel-Lock: sha1:DMmE6Kkk1WzJBXCUTRYWPEiuFIQ=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
 by: pinnerite - Wed, 16 Aug 2023 17:36 UTC

On Wed, 16 Aug 2023 07:22:16 -0600
jeorge <someone@invalid.invalid> wrote:

> On 8/16/23 4:30 AM, pinnerite wrote:
> > I picked that up from:
> >
> > https://linuxize.com/post/bash-functions/
> >
> > and chose the reserved word "function" approach.
> > After changing to: disp() { ...} as suggested, i quickly got the whole script to run smoothly.
>
> FYI - you could have used the 'function fname {...}' form but you'd need
> to change the "shabang" line to be '#!/bin/bash' ; using '#!/bin/sh'
> calls dash(1), the bash(1) version of the traditional Bourne shell which
> doesn't support the 'function' reserve word, aka a "bashism". Other
> shells such as mksh(1) also support the 'function' reserve word form
> (with optional '()' after the 'fname') but generally call it out as an
> "ignored bashism".
>
> If you find yourself writing more shell scripts you might add
> "comp.unix.shell" to your newgroup subscriptions; I've learned quite a
> bit following it.
>
> Cheers,
> jeorge

I have taken your advice and saved this message.

Thank you,

Alan

--
Linux Mint 21.1 kernel version 5.15.0-79-generic Cinnamon 5.6.8
AMD Phenom II x4 955 CPU 16Gb Dram 2TB Barracuda

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor