mirror of https://github.com/ecmwf/eccodes.git
ECC-629: grib_ls and grib_count to read standard input instead of a filename
This commit is contained in:
parent
61373165a0
commit
ea977d738a
|
@ -36,7 +36,11 @@ set -e
|
||||||
[ $status -ne 0 ]
|
[ $status -ne 0 ]
|
||||||
|
|
||||||
# With -f should count the valid messages
|
# With -f should count the valid messages
|
||||||
count=`${tools_dir}/bufr_count -f $temp`
|
vcount=`${tools_dir}/bufr_count -f $temp`
|
||||||
[ "$count" = "2" ]
|
[ "$vcount" = "2" ]
|
||||||
|
|
||||||
|
# Reading from stdin
|
||||||
|
count2=`cat $input | ${tools_dir}/bufr_count -`
|
||||||
|
[ $count -eq $count2 ]
|
||||||
|
|
||||||
rm -f $temp
|
rm -f $temp
|
||||||
|
|
|
@ -48,5 +48,14 @@ ${tools_dir}/bufr_ls -p totalLength,bufrHeaderCentre,bufrHeaderSubCentre,masterT
|
||||||
awk NR==3 $fTmp | awk '{split($0,a," "); for (i=1; i<=8; i++) print a[i]}' > $res_ls
|
awk NR==3 $fTmp | awk '{split($0,a," "); for (i=1; i<=8; i++) print a[i]}' > $res_ls
|
||||||
diff $ref_ls $res_ls
|
diff $ref_ls $res_ls
|
||||||
|
|
||||||
|
#-------------------------------------------
|
||||||
|
# Test reading from stdin
|
||||||
|
#-------------------------------------------
|
||||||
|
f="aaen_55.bufr"
|
||||||
|
cat $f | ${tools_dir}/bufr_ls -
|
||||||
|
result1=`${tools_dir}/bufr_get -p numberOfSubsets $f`
|
||||||
|
result2=`cat $f | ${tools_dir}/bufr_get -p numberOfSubsets -`
|
||||||
|
[ "$result1" = "$result2" ]
|
||||||
|
|
||||||
rm -f $fLog $res_ls
|
rm -f $fLog $res_ls
|
||||||
rm -f $fTmp
|
rm -f $fTmp
|
||||||
|
|
|
@ -88,7 +88,10 @@ int main(int argc,char* argv[])
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
filename=argv[i];
|
filename=argv[i];
|
||||||
infh=fopen(filename,"r");
|
if (strcmp(filename,"-")==0)
|
||||||
|
infh=stdin;
|
||||||
|
else
|
||||||
|
infh=fopen(filename,"r");
|
||||||
if (!infh) {
|
if (!infh) {
|
||||||
perror(filename);
|
perror(filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -286,7 +286,10 @@ static int grib_tool_without_orderby(grib_runtime_options* options)
|
||||||
while (infile!=NULL && infile->name!=NULL) {
|
while (infile!=NULL && infile->name!=NULL) {
|
||||||
|
|
||||||
if (options->print_statistics && options->verbose) fprintf(dump_file,"%s\n",infile->name);
|
if (options->print_statistics && options->verbose) fprintf(dump_file,"%s\n",infile->name);
|
||||||
infile->file = fopen(infile->name,"r");
|
if (strcmp(infile->name,"-")==0)
|
||||||
|
infile->file = stdin;
|
||||||
|
else
|
||||||
|
infile->file = fopen(infile->name,"r");
|
||||||
if(!infile->file) {
|
if(!infile->file) {
|
||||||
perror(infile->name);
|
perror(infile->name);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
Loading…
Reference in New Issue