Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #269299 > unrolled thread
| Started by | Will Mengarini <seldon@eskimo.com> |
|---|---|
| First post | 2024-05-13 18:50 +0200 |
| Last post | 2024-05-14 13:20 +0200 |
| Articles | 8 — 4 participants |
Back to article view | Back to linux.debian.user
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How to run automatically a script as soon root login Will Mengarini <seldon@eskimo.com> - 2024-05-13 18:50 +0200
Re: How to run automatically a script as soon root login Mario Marietto <marietto2008@gmail.com> - 2024-05-14 08:20 +0200
Re: How to run automatically a script as soon root login <tomas@tuxteam.de> - 2024-05-14 08:50 +0200
Re: How to run automatically a script as soon root login Greg Wooledge <greg@wooledge.org> - 2024-05-14 13:10 +0200
Re: How to run automatically a script as soon root login Greg Wooledge <greg@wooledge.org> - 2024-05-14 13:20 +0200
Re: How to run automatically a script as soon root login Mario Marietto <marietto2008@gmail.com> - 2024-05-14 15:00 +0200
Re: How to run automatically a script as soon root login Greg Wooledge <greg@wooledge.org> - 2024-05-14 17:00 +0200
Re: How to run automatically a script as soon root login Mario Marietto <marietto2008@gmail.com> - 2024-05-14 13:20 +0200
| From | Will Mengarini <seldon@eskimo.com> |
|---|---|
| Date | 2024-05-13 18:50 +0200 |
| Subject | Re: How to run automatically a script as soon root login |
| Message-ID | <IDGSu-d6rs-7@gated-at.bofh.it> |
Nobody has yet applauded this glorious implementation
of the 1960s GOTO statement in *Bash*?!
* Mario Marietto <marietto2008@gmail.com> [24-05/13=Mo 13:37 +0200]:
> function jumpto
> {
> label=$1
> cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
> eval "$cmd"
> exit
> }
Anyway, Marietto, you've got two typi:
> mid :
That should be "mid:".
> jump foo
That should be "jumpto foo".
Once you've got your root-login script working, I hope you
move on to implementing a complete open-source PL/I compiler.
[toc] | [next] | [standalone]
| From | Mario Marietto <marietto2008@gmail.com> |
|---|---|
| Date | 2024-05-14 08:20 +0200 |
| Message-ID | <IDTG1-dest-1@gated-at.bofh.it> |
| In reply to | #269299 |
[Multipart message — attachments visible in raw view] — view raw
Nobody can show a different way,a modern way, for creating my script ? Why
did I feel so comfortable by recreating the 1960s GOTO statement in Bash ?
On Mon, May 13, 2024 at 6:30 PM Will Mengarini <seldon@eskimo.com> wrote:
> Nobody has yet applauded this glorious implementation
> of the 1960s GOTO statement in *Bash*?!
>
> * Mario Marietto <marietto2008@gmail.com> [24-05/13=Mo 13:37 +0200]:
> > function jumpto
> > {
> > label=$1
> > cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
> > eval "$cmd"
> > exit
> > }
>
> Anyway, Marietto, you've got two typi:
>
> > mid :
> That should be "mid:".
>
> > jump foo
> That should be "jumpto foo".
>
> Once you've got your root-login script working, I hope you
> move on to implementing a complete open-source PL/I compiler.
>
--
Mario.
[toc] | [prev] | [next] | [standalone]
| From | <tomas@tuxteam.de> |
|---|---|
| Date | 2024-05-14 08:50 +0200 |
| Message-ID | <IDU93-deCg-1@gated-at.bofh.it> |
| In reply to | #269318 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, May 14, 2024 at 08:09:18AM +0200, Mario Marietto wrote: > Nobody can show a different way,a modern way, for creating my script ? Why > did I feel so comfortable by recreating the 1960s GOTO statement in Bash ? I think your style is too alien to most of the people here to make them feel their time is worth trying to wrap their heads around it (I just got a rough feeling on how it works, asked myself "Why?" and went on). You'll have to go it alone if you chose such an idiosyncratic style, it seems. Cheers -- t
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Date | 2024-05-14 13:10 +0200 |
| Message-ID | <IDYcG-dhcD-11@gated-at.bofh.it> |
| In reply to | #269318 |
On Tue, May 14, 2024 at 08:09:18AM +0200, Mario Marietto wrote: > Nobody can show a different way,a modern way, for creating my script ? Why > did I feel so comfortable by recreating the 1960s GOTO statement in Bash ? I have absolutely no clue what you're trying to do or why you're trying to do it, but I *promise* you, whatever you think you're doing, you have NOT recreated a GOTO statement in bash. You showed a function. Functions can be called. This is NOT the same as issuing a GOTO command, because once the function returns, control flow resumes from the point where it was called. Bash (and sh, on which bash is based) explicitly chose not to have a GOTO statement in its language. The authors chose instead to use the control primitives that are collectively known as "structured programming" (if, while, for, functions).
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Date | 2024-05-14 13:20 +0200 |
| Message-ID | <IDYml-dhg4-1@gated-at.bofh.it> |
| In reply to | #269322 |
On Tue, May 14, 2024 at 01:10:05PM +0200, Mario Marietto wrote: > Your answer does not help me to understand how to use a "structured > programming / if , while, for, functions" for the specific task that I want > to achieve. What task is that?
[toc] | [prev] | [next] | [standalone]
| From | Mario Marietto <marietto2008@gmail.com> |
|---|---|
| Date | 2024-05-14 15:00 +0200 |
| Message-ID | <IDZV7-di3b-15@gated-at.bofh.it> |
| In reply to | #269323 |
[Multipart message — attachments visible in raw view] — view raw
I've installed the Cloudflare gateway on Debian as a vm because I can't do it directly in FreeBSD. But I want to be covered even when I use FreeBSD. The script that I wrote forward the Cloudflare "VPN" from Debian to FreeBSD,so from outside my IP will be cloudFlared. On Tue, May 14, 2024 at 1:16 PM Greg Wooledge <greg@wooledge.org> wrote: > On Tue, May 14, 2024 at 01:10:05PM +0200, Mario Marietto wrote: > > Your answer does not help me to understand how to use a "structured > > programming / if , while, for, functions" for the specific task that I > want > > to achieve. > > What task is that? > > -- Mario.
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Date | 2024-05-14 17:00 +0200 |
| Message-ID | <IE1Nf-djau-15@gated-at.bofh.it> |
| In reply to | #269337 |
On Tue, May 14, 2024 at 02:51:17PM +0200, Mario Marietto wrote: > I've installed the Cloudflare gateway on Debian as a vm because I can't do > it directly in FreeBSD. But I want to be covered even when I use FreeBSD. > The script that I wrote forward the Cloudflare "VPN" from Debian to > FreeBSD,so from outside my IP will be cloudFlared. Disclaimer: I know nothing about Cloudflare. So you wrote a bash script. I will assume this script does what you want it to. You type its name to run it, or you have it set up to run at boot time, or you have it set up to run at login time, or via a cron job, or via a DHCP dhclient enter/exit hook.... Where does the GOTO come in? Do you think your script does something internally which mimics a GOTO in some way? Or that it *should* do that? Why would you need a GOTO to do whatever networking configuration steps the script does? Lacking any knowledge of Cloudflare, I'm imagining that the script simply performs a sequence of commands, in a linear order, without any branching or looping or jumping around.
[toc] | [prev] | [next] | [standalone]
| From | Mario Marietto <marietto2008@gmail.com> |
|---|---|
| Date | 2024-05-14 13:20 +0200 |
| Message-ID | <IDYml-dhg4-3@gated-at.bofh.it> |
| In reply to | #269322 |
[Multipart message — attachments visible in raw view] — view raw
Your answer does not help me to understand how to use a "structured programming / if , while, for, functions" for the specific task that I want to achieve. I failed using "your" lovely structured programming and that's the reason why I'm asking for some hint to understand why and how I can use it. Your answer puts the finger on the spot and isn't helpful, also because it says things that I already knew. On Tue, May 14, 2024 at 1:03 PM Greg Wooledge <greg@wooledge.org> wrote: > On Tue, May 14, 2024 at 08:09:18AM +0200, Mario Marietto wrote: > > Nobody can show a different way,a modern way, for creating my script ? > Why > > did I feel so comfortable by recreating the 1960s GOTO statement in Bash > ? > > I have absolutely no clue what you're trying to do or why you're trying > to do it, but I *promise* you, whatever you think you're doing, you > have NOT recreated a GOTO statement in bash. > > You showed a function. Functions can be called. This is NOT the same > as issuing a GOTO command, because once the function returns, control > flow resumes from the point where it was called. > > Bash (and sh, on which bash is based) explicitly chose not to have a GOTO > statement in its language. The authors chose instead to use the control > primitives that are collectively known as "structured programming" > (if, while, for, functions). > > -- Mario.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web