Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Row, row, row your bits, gently down the stream...


devel / comp.unix.shell / Re: The exeve system call and the exec family of functions (was: Try to understand complex sed command logic instructions.)

SubjectAuthor
* Try to understand complex sed command logic instructions.hongy...@gmail.com
`* Re: Try to understand complex sed command logic instructions.Janis Papanagnou
 +* Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
 |`* Re: Try to understand complex sed command logic instructions.Janis Papanagnou
 | `* Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
 |  `* Re: Try to understand complex sed command logic instructions.Janis Papanagnou
 |   `- Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
 +* Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
 |`* Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
 | `* Re: Try to understand complex sed command logic instructions.John-Paul Stewart
 |  `* Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
 |   `- Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
 `* Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
  `* Re: Try to understand complex sed command logic instructions.Janis Papanagnou
   `* Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
    +* Re: Try to understand complex sed command logic instructions.Janis Papanagnou
    |`* Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
    | +* Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
    | |`* The exeve system call and the exec family of functions (was: Try to understand cHelmut Waitzmann
    | | `* Re: The exeve system call and the exec family of functions (was: Tryhongy...@gmail.com
    | |  `* Re: The exeve system call and the exec family of functions (was: Tryhongy...@gmail.com
    | |   `* Re: The exeve system call and the exec family of functions (was: TryDavid W. Hodgins
    | |    `* Re: The exeve system call and the exec family of functions (was: Tryhongy...@gmail.com
    | |     `* Re: The exeve system call and the exec family of functions (was: TryDavid W. Hodgins
    | |      `- Re: The exeve system call and the exec family of functions (was: TryKenny McCormack
    | +- Re: Try to understand complex sed command logic instructions.William Unruh
    | `* Re: Try to understand complex sed command logic instructions.Janis Papanagnou
    |  `- Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
    `* Re: Try to understand complex sed command logic instructions.Keith Thompson
     `* Re: Try to understand complex sed command logic instructions.hongy...@gmail.com
      `* Re: Try to understand complex sed command logic instructions.David W. Hodgins
       `- Re: Try to understand complex sed command logic instructions.hongy...@gmail.com

Pages:12
The exeve system call and the exec family of functions (was: Try to understand complex sed command logic instructions.)

<83zgp2hn90.fsf_-_@helmutwaitzmann.news.arcor.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4743&group=comp.unix.shell#4743

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!ig8U4vHcAX7j2koXvjUl3g.user.46.165.242.75.POSTED!not-for-mail
From: nn.throt...@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: The exeve system call and the exec family of functions (was: Try to understand complex sed command logic instructions.)
Date: Tue, 14 Dec 2021 22:47:55 +0100
Organization: Aioe.org NNTP Server
Message-ID: <83zgp2hn90.fsf_-_@helmutwaitzmann.news.arcor.de>
References: <e3b2d713-b937-45c6-ab1a-6c67ee7abdacn@googlegroups.com>
<sp2577$6no$1@dont-email.me>
<f895cd0a-f2f4-4cd2-b10b-093b32527d33n@googlegroups.com>
<sp4not$5bs$1@dont-email.me>
<c10f30db-b500-4124-81b2-d8fee54da0e6n@googlegroups.com>
<sp53r6$cjh$1@dont-email.me>
<9f1c5867-5377-49fa-9583-4faa15ce8361n@googlegroups.com>
<0dc47e12-afd3-4e5b-88e2-27ca3f5d8154n@googlegroups.com>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Info: gioia.aioe.org; logging-data="33289"; posting-host="ig8U4vHcAX7j2koXvjUl3g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Mail-Copies-To: nobody
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:9DrzCBK8HKunJftNKVmHCK4U0ZU=
 by: Helmut Waitzmann - Tue, 14 Dec 2021 21:47 UTC

"hongy...@gmail.com" <hongyi.zhao@gmail.com>:

>And strace can't trace the system calls and signals of this script:
>
>$ strace ./test.sh
>execve("./test.sh", ["./test.sh"], 0x7ffc7d8136c0 /* 102 vars */) = -1 ENOEXEC (Exec format error)
>strace: exec: Exec format error
>+++ exited with 1 +++

An interpreter (here: shell) script is not a runable program
image.  That's why the system call execve, that is told to execute
that script, returns an error.

See the execve(2) and errno(3) manual pages and the POSIX error
numbers
(<https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_03>)
for what the ENOEXEC error is.

Give that script a Shebang in the first line of it, then make it
executable:

chmod -- u+x ./test.sh

Try again tracing it.  Does ist work now?

Let me append my ceterum censeo:

You really should get a book about the unix kernel, not just about
the shell.  Learn the purpose and behavior of the system calls – in
this case: the execve system call and the various wrappers for that
system call in the C language runtime library: the exec family of
functions.

Understand, what the wrapper function execlp does, when given a file
with read and execute permissions, starting with a Shebang line: 
It invokes the named interpreter, giving it the pathname of the
given (script) file as a parameter.

Then, get a book about the shell (or just read the shell manual page
and the POSIX specification
<https://pubs.opengroup.org/onlinepubs/9699919799/utilities/toc.html>),
to know, what the shell does when reading and executing a shell
script, especially:  Understand, how the shell transforms a shell
command line invoking a simple command into the corresponding execve
argument vector.

Finally, understand, why the seen "strace" behavior above follows
from the lessions learned.

As long as you don't understand the unix system calls provided by
the kernel, you'll neither understand the strace error message above
nor make progress in shell programming.

Re: The exeve system call and the exec family of functions (was: Try to understand complex sed command logic instructions.)

<59329ea0-ff25-4819-9c2a-42689c076defn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4744&group=comp.unix.shell#4744

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a37:9d44:: with SMTP id g65mr7116174qke.495.1639530505920;
Tue, 14 Dec 2021 17:08:25 -0800 (PST)
X-Received: by 2002:ac8:7d0e:: with SMTP id g14mr9628545qtb.638.1639530505737;
Tue, 14 Dec 2021 17:08:25 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 14 Dec 2021 17:08:25 -0800 (PST)
In-Reply-To: <83zgp2hn90.fsf_-_@helmutwaitzmann.news.arcor.de>
Injection-Info: google-groups.googlegroups.com; posting-host=143.198.81.107; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 143.198.81.107
References: <e3b2d713-b937-45c6-ab1a-6c67ee7abdacn@googlegroups.com>
<sp2577$6no$1@dont-email.me> <f895cd0a-f2f4-4cd2-b10b-093b32527d33n@googlegroups.com>
<sp4not$5bs$1@dont-email.me> <c10f30db-b500-4124-81b2-d8fee54da0e6n@googlegroups.com>
<sp53r6$cjh$1@dont-email.me> <9f1c5867-5377-49fa-9583-4faa15ce8361n@googlegroups.com>
<0dc47e12-afd3-4e5b-88e2-27ca3f5d8154n@googlegroups.com> <83zgp2hn90.fsf_-_@helmutwaitzmann.news.arcor.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <59329ea0-ff25-4819-9c2a-42689c076defn@googlegroups.com>
Subject: Re: The exeve system call and the exec family of functions (was: Try
to understand complex sed command logic instructions.)
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Wed, 15 Dec 2021 01:08:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 71
 by: hongy...@gmail.com - Wed, 15 Dec 2021 01:08 UTC

On Wednesday, December 15, 2021 at 5:49:14 AM UTC+8, Helmut Waitzmann wrote:
> "hongy...@gmail.com" <hongy...@gmail.com>:
> >And strace can't trace the system calls and signals of this script:
> >
> >$ strace ./test.sh
> >execve("./test.sh", ["./test.sh"], 0x7ffc7d8136c0 /* 102 vars */) = -1 ENOEXEC (Exec format error)
> >strace: exec: Exec format error
> >+++ exited with 1 +++
> An interpreter (here: shell) script is not a runable program
> image. That's why the system call execve, that is told to execute
> that script, returns an error.
>
> See the execve(2) and errno(3) manual pages and the POSIX error
> numbers
> (<https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_03>)
> for what the ENOEXEC error is.
>
> Give that script a Shebang in the first line of it, then make it
> executable:
>
> chmod -- u+x ./test.sh
>
> Try again tracing it. Does ist work now?

I've granted the execute permission to the script:

$ ls -la test.sh
-rwxrw-r-- 1 werner werner 29 Dec 15 09:02 test.sh

$ strace ./test.sh
execve("./test.sh", ["./test.sh"], 0x7ffc06199f90 /* 103 vars */) = -1 ENOEXEC (Exec format error)
strace: exec: Exec format error
+++ exited with 1 +++


>
> Let me append my ceterum censeo:
>
> You really should get a book about the unix kernel, not just about
> the shell. Learn the purpose and behavior of the system calls – in
> this case: the execve system call and the various wrappers for that
> system call in the C language runtime library: the exec family of
> functions.
>
> Understand, what the wrapper function execlp does, when given a file
> with read and execute permissions, starting with a Shebang line:
> It invokes the named interpreter, giving it the pathname of the
> given (script) file as a parameter.
>
> Then, get a book about the shell (or just read the shell manual page
> and the POSIX specification
> <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/toc.html>),
> to know, what the shell does when reading and executing a shell
> script, especially: Understand, how the shell transforms a shell
> command line invoking a simple command into the corresponding execve
> argument vector.
>
> Finally, understand, why the seen "strace" behavior above follows
> from the lessions learned.
>
> As long as you don't understand the unix system calls provided by
> the kernel, you'll neither understand the strace error message above
> nor make progress in shell programming.

Thank you for your comment.

Re: The exeve system call and the exec family of functions (was: Try to understand complex sed command logic instructions.)

<5aa5df4e-336e-4195-b5ac-2ac90258d634n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4745&group=comp.unix.shell#4745

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:6214:29c3:: with SMTP id gh3mr9166618qvb.44.1639530760751;
Tue, 14 Dec 2021 17:12:40 -0800 (PST)
X-Received: by 2002:a05:620a:141b:: with SMTP id d27mr6855578qkj.233.1639530760615;
Tue, 14 Dec 2021 17:12:40 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 14 Dec 2021 17:12:40 -0800 (PST)
In-Reply-To: <59329ea0-ff25-4819-9c2a-42689c076defn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=172.105.205.245; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 172.105.205.245
References: <e3b2d713-b937-45c6-ab1a-6c67ee7abdacn@googlegroups.com>
<sp2577$6no$1@dont-email.me> <f895cd0a-f2f4-4cd2-b10b-093b32527d33n@googlegroups.com>
<sp4not$5bs$1@dont-email.me> <c10f30db-b500-4124-81b2-d8fee54da0e6n@googlegroups.com>
<sp53r6$cjh$1@dont-email.me> <9f1c5867-5377-49fa-9583-4faa15ce8361n@googlegroups.com>
<0dc47e12-afd3-4e5b-88e2-27ca3f5d8154n@googlegroups.com> <83zgp2hn90.fsf_-_@helmutwaitzmann.news.arcor.de>
<59329ea0-ff25-4819-9c2a-42689c076defn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5aa5df4e-336e-4195-b5ac-2ac90258d634n@googlegroups.com>
Subject: Re: The exeve system call and the exec family of functions (was: Try
to understand complex sed command logic instructions.)
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Wed, 15 Dec 2021 01:12:40 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 42
 by: hongy...@gmail.com - Wed, 15 Dec 2021 01:12 UTC

On Wednesday, December 15, 2021 at 9:08:28 AM UTC+8, hongy...@gmail.com wrote:
> On Wednesday, December 15, 2021 at 5:49:14 AM UTC+8, Helmut Waitzmann wrote:
> > "hongy...@gmail.com" <hongy...@gmail.com>:
> > >And strace can't trace the system calls and signals of this script:
> > >
> > >$ strace ./test.sh
> > >execve("./test.sh", ["./test.sh"], 0x7ffc7d8136c0 /* 102 vars */) = -1 ENOEXEC (Exec format error)
> > >strace: exec: Exec format error
> > >+++ exited with 1 +++
> > An interpreter (here: shell) script is not a runable program
> > image. That's why the system call execve, that is told to execute
> > that script, returns an error.
> >
> > See the execve(2) and errno(3) manual pages and the POSIX error
> > numbers
> > (<https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_03>)
> > for what the ENOEXEC error is.
> >
> > Give that script a Shebang in the first line of it, then make it
> > executable:
> >
> > chmod -- u+x ./test.sh
> >
> > Try again tracing it. Does ist work now?
> I've granted the execute permission to the script:
>
> $ ls -la test.sh
> -rwxrw-r-- 1 werner werner 29 Dec 15 09:02 test.sh
>
> $ strace ./test.sh
> execve("./test.sh", ["./test.sh"], 0x7ffc06199f90 /* 103 vars */) = -1 ENOEXEC (Exec format error)
> strace: exec: Exec format error
> +++ exited with 1 +++

Additional information:

$ cat -A test.sh
$ #!/bin/bash$
echo 'Hello.'$

Re: The exeve system call and the exec family of functions (was: Try to understand complex sed command logic instructions.)

<op.1ee8dtrra3w0dxdave@hodgins.homeip.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4746&group=comp.unix.shell#4746

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: dwhodg...@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.unix.shell
Subject: Re: The exeve system call and the exec family of functions (was: Try
to understand complex sed command logic instructions.)
Date: Tue, 14 Dec 2021 21:40:31 -0500
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <op.1ee8dtrra3w0dxdave@hodgins.homeip.net>
References: <e3b2d713-b937-45c6-ab1a-6c67ee7abdacn@googlegroups.com>
<sp2577$6no$1@dont-email.me>
<f895cd0a-f2f4-4cd2-b10b-093b32527d33n@googlegroups.com>
<sp4not$5bs$1@dont-email.me>
<c10f30db-b500-4124-81b2-d8fee54da0e6n@googlegroups.com>
<sp53r6$cjh$1@dont-email.me>
<9f1c5867-5377-49fa-9583-4faa15ce8361n@googlegroups.com>
<0dc47e12-afd3-4e5b-88e2-27ca3f5d8154n@googlegroups.com>
<83zgp2hn90.fsf_-_@helmutwaitzmann.news.arcor.de>
<59329ea0-ff25-4819-9c2a-42689c076defn@googlegroups.com>
<5aa5df4e-336e-4195-b5ac-2ac90258d634n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="7fa08eac016def028bf01b1e58e6cc5f";
logging-data="15558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xw2EjGNtGX3gv3inXji/qFa+Yh5JnyYU="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:bywCbaOV7IABHQawVWOIvTDD8ns=
 by: David W. Hodgins - Wed, 15 Dec 2021 02:40 UTC

On Tue, 14 Dec 2021 20:12:40 -0500, hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
>> $ strace ./test.sh
>> execve("./test.sh", ["./test.sh"], 0x7ffc06199f90 /* 103 vars */) = -1 ENOEXEC (Exec format error)
>> strace: exec: Exec format error
>> +++ exited with 1 +++
>
> Additional information:
>
> $ cat -A test.sh
> $
> #!/bin/bash$
> echo 'Hello.'$

Strange.

[tester@x3 ~]$ cat -A bin/test
#!/bin/bash$
echo 'Hello.'$
[tester@x3 ~]$ bin/test
Hello.
[tester@x3 ~]$ strace bin/test
execve("bin/test", ["bin/test"], 0x7fff84f3fc70 /* 53 vars */) = 0
brk(NULL) = 0xaf8000
access("/etc/ld.so.preload", R_OK) = 0
openat(AT_FDCWD, "/etc/ld.so.preload", O_RDONLY|O_CLOEXEC) = 3
<snip rest>

[tester@x3 ~]$ bash --version
GNU bash, version 5.1.4(1)-release (x86_64-mageia-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Regards, Dave Hodgins

Re: The exeve system call and the exec family of functions (was: Try to understand complex sed command logic instructions.)

<831bf126-f579-45dd-9fbd-f16082124e93n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4747&group=comp.unix.shell#4747

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a37:6390:: with SMTP id x138mr7463074qkb.146.1639543177513;
Tue, 14 Dec 2021 20:39:37 -0800 (PST)
X-Received: by 2002:a0c:fec6:: with SMTP id z6mr4851827qvs.40.1639543177393;
Tue, 14 Dec 2021 20:39:37 -0800 (PST)
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 14 Dec 2021 20:39:37 -0800 (PST)
In-Reply-To: <op.1ee8dtrra3w0dxdave@hodgins.homeip.net>
Injection-Info: google-groups.googlegroups.com; posting-host=165.22.62.56; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 165.22.62.56
References: <e3b2d713-b937-45c6-ab1a-6c67ee7abdacn@googlegroups.com>
<sp2577$6no$1@dont-email.me> <f895cd0a-f2f4-4cd2-b10b-093b32527d33n@googlegroups.com>
<sp4not$5bs$1@dont-email.me> <c10f30db-b500-4124-81b2-d8fee54da0e6n@googlegroups.com>
<sp53r6$cjh$1@dont-email.me> <9f1c5867-5377-49fa-9583-4faa15ce8361n@googlegroups.com>
<0dc47e12-afd3-4e5b-88e2-27ca3f5d8154n@googlegroups.com> <83zgp2hn90.fsf_-_@helmutwaitzmann.news.arcor.de>
<59329ea0-ff25-4819-9c2a-42689c076defn@googlegroups.com> <5aa5df4e-336e-4195-b5ac-2ac90258d634n@googlegroups.com>
<op.1ee8dtrra3w0dxdave@hodgins.homeip.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <831bf126-f579-45dd-9fbd-f16082124e93n@googlegroups.com>
Subject: Re: The exeve system call and the exec family of functions (was: Try
to understand complex sed command logic instructions.)
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Wed, 15 Dec 2021 04:39:37 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 65
 by: hongy...@gmail.com - Wed, 15 Dec 2021 04:39 UTC

On Wednesday, December 15, 2021 at 10:40:51 AM UTC+8, David W. Hodgins wrote:
> On Tue, 14 Dec 2021 20:12:40 -0500, hongy...@gmail.com <hongy...@gmail.com> wrote:
> >> $ strace ./test.sh
> >> execve("./test.sh", ["./test.sh"], 0x7ffc06199f90 /* 103 vars */) = -1 ENOEXEC (Exec format error)
> >> strace: exec: Exec format error
> >> +++ exited with 1 +++
> >
> > Additional information:
> >
> > $ cat -A test.sh
> > $
> > #!/bin/bash$
> > echo 'Hello.'$
> Strange.

The culprit is the first empty line in the script. If I remove it, strace will work smoothly:

$ cat -A test.sh
#!/bin/bash$
echo 'Hello.'$

$ strace ./test.sh |& head
execve("./test.sh", ["./test.sh"], 0x7ffdd1b43170 /* 102 vars */) = 0
brk(NULL) = 0x55aa39c9c000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffd34810430) = -1 EINVAL (Invalid argument)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=180831, ...}) = 0
mmap(NULL, 180831, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fee6b896000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libtinfo.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\346\0\0\0\0\0\0"..., 832) = 832

$ bash --version
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Regards,
HZ


> [tester@x3 ~]$ cat -A bin/test
> #!/bin/bash$
> echo 'Hello.'$
> [tester@x3 ~]$ bin/test
> Hello.
> [tester@x3 ~]$ strace bin/test
> execve("bin/test", ["bin/test"], 0x7fff84f3fc70 /* 53 vars */) = 0
> brk(NULL) = 0xaf8000
> access("/etc/ld.so.preload", R_OK) = 0
> openat(AT_FDCWD, "/etc/ld.so.preload", O_RDONLY|O_CLOEXEC) = 3
> <snip rest>
>
> [tester@x3 ~]$ bash --version
> GNU bash, version 5.1.4(1)-release (x86_64-mageia-linux-gnu)
> Copyright (C) 2020 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>
> This is free software; you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
>
> Regards, Dave Hodgins

Re: The exeve system call and the exec family of functions (was: Try to understand complex sed command logic instructions.)

<op.1eff7zuoa3w0dxdave@hodgins.homeip.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4749&group=comp.unix.shell#4749

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: dwhodg...@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.unix.shell
Subject: Re: The exeve system call and the exec family of functions (was: Try
to understand complex sed command logic instructions.)
Date: Wed, 15 Dec 2021 00:29:49 -0500
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <op.1eff7zuoa3w0dxdave@hodgins.homeip.net>
References: <e3b2d713-b937-45c6-ab1a-6c67ee7abdacn@googlegroups.com>
<sp2577$6no$1@dont-email.me>
<f895cd0a-f2f4-4cd2-b10b-093b32527d33n@googlegroups.com>
<sp4not$5bs$1@dont-email.me>
<c10f30db-b500-4124-81b2-d8fee54da0e6n@googlegroups.com>
<sp53r6$cjh$1@dont-email.me>
<9f1c5867-5377-49fa-9583-4faa15ce8361n@googlegroups.com>
<0dc47e12-afd3-4e5b-88e2-27ca3f5d8154n@googlegroups.com>
<83zgp2hn90.fsf_-_@helmutwaitzmann.news.arcor.de>
<59329ea0-ff25-4819-9c2a-42689c076defn@googlegroups.com>
<5aa5df4e-336e-4195-b5ac-2ac90258d634n@googlegroups.com>
<op.1ee8dtrra3w0dxdave@hodgins.homeip.net>
<831bf126-f579-45dd-9fbd-f16082124e93n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="7fa08eac016def028bf01b1e58e6cc5f";
logging-data="28229"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jHD3khrCNrL+awBWpTBE63YkuGiec0II="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:9jrrmBsQbKbU71PlX65T97JHtsM=
 by: David W. Hodgins - Wed, 15 Dec 2021 05:29 UTC

On Tue, 14 Dec 2021 23:39:37 -0500, hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:

> On Wednesday, December 15, 2021 at 10:40:51 AM UTC+8, David W. Hodgins wrote:
>> On Tue, 14 Dec 2021 20:12:40 -0500, hongy...@gmail.com <hongy...@gmail.com> wrote:
>> >> $ strace ./test.sh
>> >> execve("./test.sh", ["./test.sh"], 0x7ffc06199f90 /* 103 vars */) = -1 ENOEXEC (Exec format error)
>> >> strace: exec: Exec format error
>> >> +++ exited with 1 +++
>> >
>> > Additional information:
>> >
>> > $ cat -A test.sh
>> > $
>> > #!/bin/bash$
>> > echo 'Hello.'$
>> Strange.
>
> The culprit is the first empty line in the script. If I remove it, strace will work smoothly:

Ah. Yes. I didn't notice the leading blank line. The shebang must
be the first characters in the file.
#! = interpreted script
..ELF = Executable and Linking Format files
MZ = dos executable
etc

Regards, Dave Hodgins

Re: The exeve system call and the exec family of functions (was: Try to understand complex sed command logic instructions.)

<spbv84$1siom$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4750&group=comp.unix.shell#4750

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: The exeve system call and the exec family of functions (was: Try
to understand complex sed command logic instructions.)
Date: Wed, 15 Dec 2021 05:42:28 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <spbv84$1siom$1@news.xmission.com>
References: <e3b2d713-b937-45c6-ab1a-6c67ee7abdacn@googlegroups.com> <op.1ee8dtrra3w0dxdave@hodgins.homeip.net> <831bf126-f579-45dd-9fbd-f16082124e93n@googlegroups.com> <op.1eff7zuoa3w0dxdave@hodgins.homeip.net>
Injection-Date: Wed, 15 Dec 2021 05:42:28 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1985302"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Wed, 15 Dec 2021 05:42 UTC

In article <op.1eff7zuoa3w0dxdave@hodgins.homeip.net>,
David W. Hodgins <dwhodgins@nomail.afraid.org> wrote:
>On Tue, 14 Dec 2021 23:39:37 -0500, hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
>
>> On Wednesday, December 15, 2021 at 10:40:51 AM UTC+8, David W. Hodgins wrote:
>>> On Tue, 14 Dec 2021 20:12:40 -0500, hongy...@gmail.com <hongy...@gmail.com> wrote:
>>> >> $ strace ./test.sh
>>> >> execve("./test.sh", ["./test.sh"], 0x7ffc06199f90 /* 103 vars */) = -1
>ENOEXEC (Exec format error)
>>> >> strace: exec: Exec format error
>>> >> +++ exited with 1 +++
>>> >
>>> > Additional information:
>>> >
>>> > $ cat -A test.sh
>>> > $
>>> > #!/bin/bash$
>>> > echo 'Hello.'$
>>> Strange.
>>
>> The culprit is the first empty line in the script. If I remove it, strace will
>work smoothly:
>
>Ah. Yes. I didn't notice the leading blank line. The shebang must
>be the first characters in the file.
>#! = interpreted script
>.ELF = Executable and Linking Format files
>MZ = dos executable
>etc
>
>Regards, Dave Hodgins

At some point in the not too distant future, he's going to post some
unexplainable result - where weird error messages are coming out at the
simplest commands - and it turn out, eventually, that the problems all
started when he smashed his hard drive with a hammer.

.... And we'll all just say, well, see, you should have mentioned that
earlier...

--
http://www.rollingstone.com/politics/news/the-10-dumbest-things-ever-said-about-global-warming-20130619

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor