Problems with redirection of output to files through shell scripts

2007-09-11 Thread Pratiksha Powar
Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux
Compiler: gcc -I/usr/src/packages/BUILD/bash-3.0
-L/usr/src/packages/BUILD/bash-3.0/../readline-5.0
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i586'
-DCONF_OSTYPE='linux' -DCONF_MACHTYPE='i586-suse-linux'
-DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib   -O2 -march=i586
-mtune=i686 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g
-D_GNU_SOURCE -Wall -pipe -g -fbranch-probabilities
uname output: Linux linux 2.6.13-15-smp #1 SMP Tue Sep 13 14:56:15 UTC
2005 i686 i686 i386 GNU/Linux
Machine Type: i586-suse-linux

Bash Version: 3.0
Patch Level: 16
Release Status: release

Description:

Problem 1:

Following is the code (in a shell script)which redirects find command
output to a file called "src". But this command generates a file called
"src?" instead.

SOURCE_PATH="src"
rm -f $SOURCE_PATH
#Getting all OPS src files
find ../../com/onmobile/noc/common -name *.java > src

Problem 2:
-
Later I need to read the src file.
To circumvent Problem 1, if I use the below code :

SOURCE="$SOURCE_PATH?"
$JAVA_HOME/bin/javac -classpath $CLASSPATH -d $OUTPUT_PATH -sourcepath <
cat $SOURCE

I receive following error:
cat: No such file or directory

Could this problem be solved?

I'm facing this problem even in CentOS 10.0
Bash Version: GNU bash, version 3.1.17(1)-release
(i686-redhat-linux-gnu)

Repeat-By:


Fix:

Thanks,
Pratiksha





Re: Problems with redirection of output to files through shell scripts

2007-09-11 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Pratiksha Powar on 9/11/2007 3:44 AM:
> Bash Version: 3.0
> Patch Level: 16

Bash is now at 3.2 patchlevel 25.  You may want to consider upgrading.

> Following is the code (in a shell script)which redirects find command
> output to a file called "src". But this command generates a file called
> "src?" instead.

Sounds to me like your script has spurious carriage returns or other
invisible characters.  For the cygwin release of bash, I have added a
downstream patch to provide a shell option igncr, named after the stty
option, that makes bash ignore all carriage returns on input, when
enabled.  Is there any interest in having that option on all platforms,
rather than just Cygwin?  If so, I will try to clean up the patch and post
it here.

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

Eric Blake [EMAIL PROTECTED]
-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

iD8DBQFG5oWy84KuGfSFAYARAiK+AKCB5faqrKs6i0cux7AbwA+Gu1CAtgCeMgTK
JKBjgWM5Qh95noVCvtIFm/I=
=BJ7m
-END PGP SIGNATURE-




Wrong input confuses bash's arithmetic unit permanently

2007-09-11 Thread Enrico Scholz
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-redhat-linux-gnu' 
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  -D_GNU_SOURCE 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall 
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic 
-fasynchronous-unwind-tables
uname output: Linux kosh.bigo.ensc.de 2.6.22.3-ensc-1 #1 SMP PREEMPT Thu Aug 16 
23:36:51 CEST 2007 i686 i686 i386 GNU/Linux
Machine Type: i686-redhat-linux-gnu

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

Description:

A syntactical wrong statement will confuse bash permanently so that 
arithmetic operations return wrong results.


Repeat-By:
[copy from https://bugzilla.redhat.com/show_bug.cgi?id=286861]
$ i=0
$ let ++i
$ echo $i
1

$ let tmp="foo.a"+0
bash: let: tmp=foo.a+0: syntax error: invalid arithmetic...

$ i=0
$ let ++i
$ echo $i
0

--> every further use of 'let' will generate bogus results. bash-3.1 returns
expected results.




-d option not working. . .?

2007-09-11 Thread Michael Williams

Hi All,

I've got a script that I'm trying to set up, but it keeps telling me  
that  "[-d command not found".  Can someone please explain what is  
wrong with this?:





#!/bin/sh

for i in $*
do
{
if  [-d $i]
then
echo "$i is a directory! Yay!"
else
echo "$i is not a directory!"
fi
}
done



Regards,
Michael




Re: -d option not working. . .?

2007-09-11 Thread Bob Proulx
Michael Williams wrote:
>   if  [-d $i]

That is not the correct syntax.  The [ is a shell builtin, not a shell
metacharacter.  Shell metacharacters do not need to be separated by
whitespace but the test program needs to be apart or it won't be
parsed right.  That is why you are seeing "[-d" not found.  It is not
a parenthesis as in some programming languages.  The [ is a synonym
for the "test" operator.  It is a command like grep, sed, awk, etc.

  [ -d /tmp ] && echo /tmp is a dir

Do it this way.

  if [ -d "$i" ]

Note that you should quote the argument to protect against whitespace
there.

Bob