Quotes problem ?

2007-01-10 Thread Markos

Hello , 
I'm having problems with the script I send below.

Problem description:

I'm trying to run a script called logo_changer.sh that creates a file called
results containing different lines 
and every line is a path to a dir where the "logo_1.gif" file is located.
After the 
results file is filled, I try to read it line by line, go to every dir
refered in that line,
check the size of the "logo_1.gif" file in that dir and then store both path
and size of every 
"logo_1.gif" file founded on the system in a file called report.

I run bash -x logo_changer.gif and the result is this:
...
[cut some lines here with same message]
...
+ sed -n '$line_number"p"' /tmp/results
/tmp/logo_changer.sh: : No such file or directory
+ cd
+ pwd
+ ls -go logo_1.gif
logo_1.gif: No such file or directory
+ awk '{print $3}' /tmp/size
+ echo
+ line_number=line_number+1
+ i=6
+ '[' 6 -le 5 ']'

can anybody reproduce the problem and tell me what is wrong?



#!/usr/local/bin/bash
#Execute it from /ecas

#We search for the string logo_1.gif and store the resulting paths in
results_1

find . -name logo_1.gif >/tmp/results_1

#Delete "logo_1.gif" string from every line in results_1,
#leaving only the path to prepare for "cd" step

sed 's/logo_1.gif//' /tmp/results_1 >/tmp/results

#Initialization of variables
i="1"
line_number="1" #every line (dir path) stored in results
path=""

while [ "$i" -le "5" ]#In fact it contains more than 5 of course...
do

#Start taking line by line and store it the path variable

sed -n $line_number"p" /tmp/results >"$path"

#We change to dir stored in the path variable

cd $path

#Print actual path into /tmp/report to check later

pwd >>/tmp/report

#Take the size of logo_1.gif file from current dir

ls -go logo_1.gif >/tmp/size

#Print actual file size into /tmp/report to check later

awk '{print $3}' /tmp/size >>/tmp/report

#Print a blank line at the report after every path and size to see things
clearer

echo >>/tmp/report

#Update variables 

line_number=line_number+1
i=$[$i+1]

done
-- 
View this message in context: 
http://www.nabble.com/Quotes-problem---tf2952284.html#a8256981
Sent from the Gnu - Bash mailing list archive at Nabble.com.



___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: Quotes problem ?

2007-01-10 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Markos on 1/10/2007 5:49 AM:
> Hello , 
> I'm having problems with the script I send below.
> 
> ...
> + sed -n '$line_number"p"' /tmp/results
> /tmp/logo_changer.sh: : No such file or directory
> + cd
> + pwd
> + ls -go logo_1.gif
> logo_1.gif: No such file or directory

You failed to mention your platform.  However, my guess would be that you
are on cygwin, and that your script has CRLF line endings even though you
told cygwin to respect CR as a literal character rather than ignoring it
(because you used a binary instead of a text mount).  The output messages
resemble a rash of similar messages reported to the cygwin list for the
same root cause.  If my ESP is strong enough to have correctly diagnosed
your problem, then the fix is simple - remove the CR from your script by
running d2u on it.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
volunteer bash port maintainer for cygwin
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFpOLe84KuGfSFAYARAnRoAKCL9G2+OB3f0WTUTsclijk3nq8QHgCgtGsb
wREx7tNwrcT5t7eQAXxNY6k=
=4/zK
-END PGP SIGNATURE-


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Typo in variables.c prevents compiling on QNX6

2007-01-10 Thread James Ingraham


Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: nto-qnx6.3.2
Compiler: qcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='nto-qnx6.3.2' -DCONF_MACHTYPE='i386-pc-nto-qnx6.3.2' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H -Dqnx -Dqnx6  -I. -I. -I./include -I./lib -I./lib/intl 
-I/root/open/bash-3.2/lib/intl -g -O2
uname output: QNX EA33a7ae 6.3.2 2006/03/16-14:19:50EST x86pc x86 
Machine Type: i386-pc-nto-qnx6.3.2 

Bash Version: 3.2
Patch Level: 0
Release Status: release 

Description:
 Typo on line 29 of variables.c prevents compiling in QNX 6.x 

Repeat-By:
 NA 

Fix:
 insert the missing "s" on line 29 of variables.c: 
#   include 
becomes:
#   include 


Sincerely,
James Ingraham
Software Development Team Leader
Sage Automation, Inc.
www.sagerobot.com 
___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: Quotes problem ?

2007-01-10 Thread Paul Jarc
Markos <[EMAIL PROTECTED]> wrote:
> #Delete "logo_1.gif" string from every line in results_1,
> #leaving only the path to prepare for "cd" step
>
> sed 's/logo_1.gif//' /tmp/results_1 >/tmp/results

This would be more precisely expressed as:
sed 's:/logo_1\.gif$:/:' /tmp/results_1 >/tmp/results

If you happen to have a directory contining "logo_1.gif" in its name,
your version won't do what you want.

> sed -n $line_number"p" /tmp/results >"$path"

">" doesn't do what you want.  It redirects the output of a command to
a file.  If you want to store the output in a shell variable, use
this:
path=$(sed -n "$line_number"p /tmp/results)

> #We change to dir stored in the path variable
>
> cd $path

Quotes would be useful here, in case you have a directory name
containing spaces.


paul


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash