A hopefully quick question on the a problem that should be
common enough:
I have a script on a server. In this server files
arrive let's say randomly in bursts.
These files have a size (whan gzipped) of about 150K maximum. They arrive in
a proprietary zipped format. The task I am doing is:
1) use the proprietary program to unzip them,
2) use gzip on them (gzip -q9 file)
3) ftp them to another server
4) remove them.
The problem is that some files come corrupted,
I am not sure why this happens. COuld it be that
I am trying to unzip and then gzip a file that is still
"coming"?
If so, is there a standard practice in shell scripts
to prevent this. I suppose you cannot 'lock' the file, so
the best solution I can think of is
to put a delay or to go to sleep if the number of files
found is less than 2 (meaning the file may be still "in transit"
or something like that.
How does one implement in sh
if(number of files in the current directory <2){....}
?
Any other ideas/suggestions/things to check are greatly
appeciated.
P.S. Ordinarily I would use something like perl for the
jo except it is not installed on this machine and
I am not allowed to install it
svar
common enough:
I have a script on a server. In this server files
arrive let's say randomly in bursts.
These files have a size (whan gzipped) of about 150K maximum. They arrive in
a proprietary zipped format. The task I am doing is:
1) use the proprietary program to unzip them,
2) use gzip on them (gzip -q9 file)
3) ftp them to another server
4) remove them.
The problem is that some files come corrupted,
I am not sure why this happens. COuld it be that
I am trying to unzip and then gzip a file that is still
"coming"?
If so, is there a standard practice in shell scripts
to prevent this. I suppose you cannot 'lock' the file, so
the best solution I can think of is
to put a delay or to go to sleep if the number of files
found is less than 2 (meaning the file may be still "in transit"
How does one implement in sh
if(number of files in the current directory <2){....}
?
Any other ideas/suggestions/things to check are greatly
appeciated.
P.S. Ordinarily I would use something like perl for the
jo except it is not installed on this machine and
I am not allowed to install it
svar