why does it says "afile:cannot execute binary file"
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
why does it says "afile:cannot execute binary file"
I am trying to combine two kinds of files(afile and bfile),and make it into one file,so I write a.pl to do the work and use the shell script to finish the whole process,for both afiles and bfiles have 1000 pieces.
but when i run it,it returns "
/a/afile_002:cannot execute binary file
/b/bfile_002:cannot execute binary file
"
(afile and bfile don't have any extension names)
the a.pl is like following:
#! /usr/bin/perl
if (@ARGV != 2) {
my $help = << "end_of_help;";
Usage: a.pl <afile> <bfile>
end_of_help;
print $help;
exit;
}
my $afile = shift @ARGV;
my $bfile = shift @ARGV;
open A, "$afile" or die "error opening afile! $!\n";
open B, "$afile" or die "error opening afile! $!\n";
while($str1=<$afile>&&$str2=<$bfile>){
$string=$string.$str1;
$string=$string.$str2;
}
print $string;
And the shell script is:
i=1
pbfile=""
tbfile=""
while test $i -lq 1000
do
if test $i -le 10
then
$bfile '/b/b_00'$i''
$afile '/a/a_00'$i''
elif test $i -lt 100
then
$bfile '/b/b_0$i'
$afile '/a/a_0$i'
elif test $i -lt 1000
then
$bfile '/b/b_$i'
$afile '/a/a_$i'
Actually I made
"$bfile="/b/b_00i"
$afile="/a/a_00$i"
at first.but it says "=/a/a_001:file or directory not exsist"
so I tried to change it this way ,
it just said"afile:cannot execute binary file".
do I make it clear?
Not precisely on your question, but I think that unless the files have the same number of lines, then the while loop in your perl script will miss the last lines of the longer file will not appear in the output.
in fact I intended to build the final file according to the shorter file,that is if afile has less lines,then when afile is over, so is the final file.
now I can partly handle this problem.
but I now face another one when I try to export the final file which combine afile and bfile.
Do you friends have any ideas that how can I change my shell script,so that I can make it.
by the way ,I am using the bash.
a.pl and the shell script have been showed in the thread,aren't they?
export the results means, I want to create the cfile_001,for example, which combines afile_001 and bfile_001,and so from 001 to 1000,I can get 1000 cfiles.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.