Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #168781
| From | David Wright <deblis@lionunicorn.co.uk> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: bash help please |
| Date | 2016-06-10 07:40 +0200 |
| Message-ID | <rInkK-vX-37@gated-at.bofh.it> (permalink) |
| References | <rIkGd-74R-1@gated-at.bofh.it> <rIlLX-7Pi-9@gated-at.bofh.it> <rImRH-lD-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri 10 Jun 2016 at 01:04:40 (-0400), Gene Heskett wrote:
> On Thursday 09 June 2016 23:50:35 David Wright wrote:
> > On Thu 09 Jun 2016 at 22:41:27 (-0400), Gene Heskett wrote:
> > > A bash script that has worked most of a decade now refuses.
> > >
> > > For instance, assume that var InMail is = "gene", and can be echoed
> > > from the command line using $InMail like this.
> > > gene@coyote:~$ echo $InMail
> > > gene
> > > But I'll be switched if I can get a result from a line of code
> > > resembling this from the command line while attempting to
> > > troubleshoot a 110 line bash script: which asks "if test [${InMail}
> > > = "gene"]
> > > then
> > > -----
> > > elif (another name)
> > > yadda yadda
> > >
> > > gene@coyote:~$ echo `test [${InMail} = "gene"]`
> > >
> > > All I get is the linefeed. Obviously I'm losing it, so how do I
> > > translate and get usefull output for troubleshooting?
> >
> > $ `[ ${InMail} = "gene" ]` ; echo $?
> > 0
> > $ `[ ${InMail} = "xgene" ]` ; echo $?
> > 1
> > $ `test ${InMail} = "gene"` ; echo $?
> > 0
> > $ `test ${InMail} = "xgene"` ; echo $?
> > 1
> > $
> >
> > elif needs [], not (), and it needs a then too.
> >
> > [ is a command like test, so it must be followed by a space
> > before its argument.
> >
> > Often the easiest way of solving these is grep -A ... used with
> > /etc/init.d/*
>
> This script is home brew, and has never had a starter in /etc/init.d
Um, not my intention to make you try.
Look, /etc/init.d/* is a collection of scripts that work.
grep searches files for patterns.
Put them together and you can bash away by example. Try
$ grep -A 6 -B 6 elif /etc/init.d/* | less
and you will get lots of examples of multiple tests involving strings
(like yours), numbers, arithmetic xpressions etc. all syntactically
correct. Copy what you need, either from there or the original file.
Cheers,
David.
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
bash help please Gene Heskett <gheskett@shentel.net> - 2016-06-10 04:50 +0200
Re: bash help please Lars Noodén <lars.nooden@gmail.com> - 2016-06-10 05:10 +0200
Re: bash help please Gene Heskett <gheskett@shentel.net> - 2016-06-10 06:40 +0200
Re: bash help please David Wright <deblis@lionunicorn.co.uk> - 2016-06-10 06:00 +0200
Re: bash help please Gene Heskett <gheskett@shentel.net> - 2016-06-10 07:10 +0200
Re: bash help please David Wright <deblis@lionunicorn.co.uk> - 2016-06-10 07:40 +0200
Re: bash help please Gene Heskett <gheskett@shentel.net> - 2016-06-10 08:40 +0200
Re: bash help please David Christensen <dpchrist@holgerdanske.com> - 2016-06-10 06:10 +0200
Re: bash help please Gene Heskett <gheskett@shentel.net> - 2016-06-10 07:10 +0200
Re: bash help please David Christensen <dpchrist@holgerdanske.com> - 2016-06-11 05:50 +0200
Re: bash help please <tomas@tuxteam.de> - 2016-06-10 09:10 +0200
csiph-web