General discussion

Locked

Data loss when copying files

By Rotaluclac ·
I experience random loss of data when merely copying files via Telnet on the Redhat Linux 7.2 system of my ISP using Bash. My ISP cannot solve the problem. Maybe you've got a hint?

I can reproduce the problem using the following test script:===== begin script =====
#!/bin/bash

ORIGINAL=./Trompmail.html.original
VICTIM=./Trompmail.html
TEMPFILE=~/temp/update.$(date '+%H%M%S').$$.0

cp $ORIGINAL $VICTIM

i=10000
while [ $i -gt 0 ]
do
sed 's/\([^ \t]\) *\(\.\,\!\?\;\:\)/\1\2/g' $VICTIM >$TEMPFILE
cp $TEMPFILE $VICTIM
ls -l $VICTIM | grep -w 0
if [ $? -eq 0 ]
then
i=0
fi
i=$(($i-1))
done

if [ $i -eq 0 ]
then
echo Success
else
echo Failure
fi
====== end script ======
After a while, the script reports Failure because the file size is zero. Before that happens, cp may report the following problems:

"cp: cannot create regular file `./Trompmail.html': Input/output error"

or

"cp: closing `./Trompmail.html': Input/output error"

but these messages do not imply that the file size has reduced to zero.

What's happening? More importantly, what can I do to prevent this problem? (The original script is quite lengthy, so inserting sleep 1 commands is not an option.)

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Data loss when copying files

by Skizz In reply to Data loss when copying fi ...

You could try removing both the copy statements.
They aren't really needed. Just perform the sed on $ORIGINAL and output it to $VICTIM

Collapse -

Data loss when copying files

by Rotaluclac In reply to Data loss when copying fi ...

I know the copy statements are not needed. The entire script is not needed. It is a DEMO script, intended to demonstrate the problem.

The question is: WHY is the file size reduced to zero? WHY do I get those error messages?

Collapse -

by Rotaluclac In reply to Data loss when copying fi ...

This question was auto-closed because it is 90 days old

Collapse -

by Rotaluclac In reply to Data loss when copying fi ...

This question was auto-closed because it is 90 days old

Back to Linux Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums