🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #10385

Re: [bash] test: too many arguments

#10385
From: Claudio S.
Date: Sun, 03 Mar 2002 15:15
51 lines
2675 bytes
El Fri, 1 Mar 2002 21:37:09 +0100, Benjam�n Albi�ana
<benjamin@lamanonegra.net.dhis.org> escribi�:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
>   Estoy intentando hacer un script en bash que mire si hay ficheros en
>   un directorio, y si es as�, que los mueva a otro, y los pase por
>   otro script. Una vez hecho esto, que lance un programa. 
> 
> - -----------------------------------------------------------------------
> #!/bin/bash
> if test ! -z $(dir -1 /var/spool/news/failed.postings/)
> then
> mv /var/spool/news/failed.postings/* /var/spool/news/out.going
> cd /var/spool/news/out.going
> for i in $(dir -1)
> do
> 	/usr/local/bin/toqueteo $i
> done
> fi
> cd /tmp
> su -c "/usr/sbin/fetchnews -nvvv" news
> - -----------------------------------------------------------------------
> 
>   El caso es que me da el siguiente error: 
> 
>    sh -x noticias4
>    ++ dir -1 /var/spool/news/failed.postings/
>    + test '!' -z 17626-1014994423-1 17626-1014995334-2
>    17626-1014995688-3 17626-1014996193-4
>    noticias4: test: too many arguments
>   
>   Llevo un par de d�as dandole vueltas, y no soy capaz de ver d�nde
>   est� el problema. �Alguna idea? 

Hola Benjam�n:

  Ya te han dado una soluci�n. Solo a�adir que para comprobar la
  existencia de archivos debe ser mejor -f ( � -e si quieres tener
  en cuenta tambi�n links, directorios, etc).

  if [ -f /var/spool/news/failed.postings/* ]; then
     mv /var/spool/news/failed.postings/* /var/spool/news/out.going
  fi
  for i in /var/spool/news/out.going/* ; do
    ...
  done

Un saludo.
--claudio--
Technical Details
Message-ID: <olet5a.i61.ln@127.0.0.1>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!139.red-80-59-173.pooles.rima-tde.NET!not-for-mail
References: <slrna7vpjf.mlg.benjamin@lamanonegra.net.dhis.org>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,f967119e962785f0
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-03-03 08:05:52 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!139.red-80-59-173.pooles.rima-tde.NET!not-for-mail
From: "Claudio S." <claudio@dev.null.org>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: [bash] test: too many arguments
Date: Sun, 3 Mar 2002 16:15:04 +0100
Lines: 51
Message-ID: <olet5a.i61.ln@127.0.0.1>
References: <slrna7vpjf.mlg.benjamin@lamanonegra.net.dhis.org>
NNTP-Posting-Host: 139.red-80-59-173.pooles.rima-tde.net (80.59.173.139)
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: fu-berlin.de 1015171549 10398773 80.59.173.139 (16 [130458])
X-Orig-Path: 127.0.0.1!nobody
User-Agent: slrn/0.9.7.3 (Linux)