RE: shell script error






I think that by changing the command, you worked around the problem.

the real solution is to look at the syntax of the command "test"  which is
written here as "[" and "]"
[  "whatever you want tested" ] is an alternative way of writing test
"whatever you want tested"
now,  knowing that the brackets are a command,  it is clear that it needs
spaces around the brackets!  ("echosomething" is different from "echo
something")
i didn't see any in your original failing commandline.

BTW the final fgrep solution without test is nicer though

Kind Regards,
Matthijs Sneijders
|--------------------------------------------------------------------------|
|Matthijs Sneijders |
|--------------------------------------------------------------------------|
|-----+---------------------------------+-----------------|
| |CORUS Research, Development & | |
| |Technology | |
|-----+---------------------------------+-----------------|
| |Building 3G16 room 3-337 | |
|-----+---------------------------------+-----------------|
| |P.O. Box 10.000 | |
|-----+---------------------------------+-----------------|
| |1970 CA IJMUIDEN | |
|-----+---------------------------------+-----------------|
| |phone |+31 (0)251-496400|
|-----+---------------------------------+-----------------|
| |fax |+31 (0)251-470064|
|-----+---------------------------------+-----------------|
| |mail |matthijs.sneijder|
| | |s@xxxxxxxxxxxxxx |
|-----+---------------------------------+-----------------|
|-----------------------------+-------------------------------------------|
|"Steven Buehler" | |
|<steve@xxxxxxxxxxxx> | |
|Sent by: | To|
|redhat-list-bounces@xxxxxxxxx| "'General Red|
|m | Hat Linux |
| | discussion |
|07-12-2007 02:00 | list'" |
| | <redhat-list@|
| Please respond to | redhat.com> |
| General Red Hat Linux | cc|
| discussion list | |
| <redhat-list@xxxxxxxxxx> | Subject|
| | RE: shell |
| | script error |
| | |
| | |
| | |
| | |
| | |
| | |
|-----------------------------+-------------------------------------------|











Thank You very much.  That did the trick.

-----Original Message-----
From: redhat-list-bounces@xxxxxxxxxx [mailto:redhat-list-
bounces@xxxxxxxxxx] On Behalf Of Cesar Covarrubias
Sent: Thursday, December 06, 2007 12:14 PM
To: General Red Hat Linux discussion list
Subject: Re: shell script error

Hello,

If my shell programming is as good as I hope, you need the following:

if [ ! -z `/bin/cat /tmp/BACKUP/tmp | /bin/grep 'not accepted'` ] ;
then
echo hi; else echo no; fi

The -z will apply the the output of the entire line, after the grep. I
am sure if I am wrong, someone will be sure and educate us both and
make
us better shell programmers.

Very Respectfully,
Cesar Covarrubias

On Thu, 2007-12-06 at 12:00 -0600, Steven Buehler wrote:
I hope this is the right list to ask this on.  I am creating a shell
script
for something and the following line (whether run from the script or
the
command line) gives me an error:
if [ ! -z /bin/cat /tmp/BACKUP/tmp | /bin/grep 'not accepted' ] ;
then echo
hi; else echo no; fi

Gives me the following error
-------------
-bash: [: missing `]'
grep: ]: No such file or directory
no
-------------

If I run the command like the following, it works just fine:
/bin/cat /tmp/BACKUP/tmp | /bin/grep 'not accepted'

Any help would be appreciated.

Thanks
Steve


--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

**********************************************************************
This transmission is confidential and must not be used or disclosed by
anyone other than the intended recipient. Neither Corus Group Limited nor
any of its subsidiaries can accept any responsibility for any use or
misuse of the transmission by anyone.

For address and company registration details of certain entities
within the Corus group of companies, please visit
http://www.corusgroup.com/entities

**********************************************************************


--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list



Relevant Pages

  • Re: script question
    ... echo $line ... ...except a script that actually works. ... Remember a shell is a command line interpreter, ... most alien way to do shell programming. ...
    (comp.unix.questions)
  • Re: shell script error
    ... If my shell programming is as good as I hope, ... echo hi; else echo no; fi ... The -z will apply the the output of the entire line, after the grep. ... If I run the command like the following, ...
    (RedHat)
  • Re: 2.6.33-rc1: LZMA kernel fails to decompress
    ... size_append command scripts/Makefile.lib. ... Specifying the full path forces to use the system echo command ... In 2.6.33, for some reason, echo has been replaced with printf. ... real solution, which is to stop doing all this hackery altogether, ...
    (Linux-Kernel)
  • Re: Terminal Help: Stuck Again
    ... I apparently type the wrong thing and the prompt ... You have typed an incomplete command, and the ">" is the secondary ... first echo command is to be the standard input of another command. ... In shell programming, it is common to have chained ...
    (comp.sys.mac.system)
  • Re: [SLE] find (and locate)
    ... Carlos E. R. wrote: ... >>Beside the fact that it isn't a real solution and not ... But the following command: ... simply stopped searching before the very end. ...
    (SuSE)