bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problems with output redirection


From: Bert Barbe
Subject: Re: problems with output redirection
Date: Wed, 02 Apr 2008 11:22:58 +0200
User-agent: Thunderbird 2.0.0.12 (Windows/20080213)

Interesting would be to see how the file looks like on the other hosts ;)
Maybe the file is being extended on the remote host first but the write() isn't synced before the local host writes again. Why not redirect the output off ssh locally so that all writes are local ? That is if the output isn't huge ofcourse.
I would imagine this is more of an nfs issue than a bash issue.

Regards,
Bert

Verena Alishahi wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear list-members,

last week I've updated my workstation cluster client (amd 64 bit) from
SuSE 10.0 to openSUSE 10.3. My bash-version is 3.2.25(1)-release.

Now I've problems with a bash script, which I used (with bash 3.1) for
years without any problems. I really don't understand what's going on.

I've reduced my original script to a minimal script which reproduces the
output redirection error. The script works as follows:

My first script (local.sh) reads a list of worksation cluster clients
from hosts.inp in a loop and prints some output to output.txt. In the
loop a second script (remote.sh) is called in a ssh instruction.
remote.sh then writes some output to the same output.txt file, but this
output doesn't reach the output file correctly.

Both the bash-scripts and the output file are stored on an
NFS-Filesystem (on the workstation cluster server), so every client can
access them.

| less hosts.inp
client1
client2
client3
client4

| less local.sh
#!/bin/bash
OUTPUT=$HOME/bashtest/output.txt
INPUT_HOSTS=$HOME/bashtest/hosts.inp
REMOTE_SKRIPT=$HOME/bashtest/remote.sh
echo "created from $HOME/bashtest/local.sh" > $OUTPUT
for HOST in `cat $INPUT_HOSTS`
do
~  echo $HOST >> $OUTPUT
~  ssh $HOST $REMOTE_SKRIPT
~  echo "" >> $OUTPUT
done

| less remote.sh
#!/bin/bash
OUTPUT=$HOME/bashtest/output.txt
echo "TEST2" >> $OUTPUT

| less output.txt
created from /home/user1/bashtest/local.sh
client1
^@^@^@^@^@^@
client2
^@^@^@^@^@^@
client3
^@^@^@^@^@^@
client4
^@^@^@^@^@^@


Instead of all the ^@^@^@^@^@^@ rows, output.txt should contain the text
TEST2
less thinks output.txt were a binary file.
I don't understand, why the output-redirection in remote.sh doesn't
work. If I do the output-redirection in remote.sh to another file, for
example
OUTPUT2=$HOME/bashtest/output2.txt
echo "TEST2" >> $OUTPUT2
then it works.
The output-redirection only fails, when the redirection is to the same
file which is also be written from local.sh.

I appreciate receiving any help.

best regards,
Verena Alishahi
- --

Verena Alishahi

Institut für Chemie und Dynamik der Geosphäre
ICG-1: Stratosphäre
Tel.: +49 2461 61-6221
E-Mail: v.alishahi@fz-juelich.de

- -------------------------------------------------------------------------- - --------------------------------------------------------------------------
Forschungszentrum Jülich GmbH
52425 Jülich

Sitz der Gesellschaft: Jülich
Eingetragen im Handelsregister des Amtsgerichts Düren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDirig'in Bärbel Brumme-Bothe
Geschäftsführung: Prof. Dr. Achim Bachem (Vorsitzender), Dr. Ulrich Krafft
(stellv. Vorsitzender); Dr. Sebastian M. Schmidt
- -------------------------------------------------------------------------- - --------------------------------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFH80XdB/rJPqfoUGARAsxsAKDW/2VyTD9vZ5hwqaBHetahrkUCTgCghVVP
6L93pwaFPbfj7O3w0IjOdSs=
=+SC6
-----END PGP SIGNATURE-----


-------------------------------------------------------------------
-------------------------------------------------------------------
Forschungszentrum Jülich GmbH
52425 Jülich

Sitz der Gesellschaft: Jülich
Eingetragen im Handelsregister des Amtsgerichts Düren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Bärbel Brumme-Bothe
Geschäftsführung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
Dr. Sebastian M. Schmidt
-------------------------------------------------------------------
-------------------------------------------------------------------






reply via email to

[Prev in Thread] Current Thread [Next in Thread]