LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-29-2007, 08:35 PM   #1
littletransformer
LQ Newbie
 
Registered: Nov 2007
Posts: 18

Rep: Reputation: 0
Unhappy 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'

fi

/usr/bin/perl /perl/bin/a.pl $afile $bfile

((i=$i+1))
done
 
Old 11-30-2007, 12:49 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You don't actually define the values for $afile, $bfile before using in the shell file here:
$bfile '/b/b_00'$i''
$afile '/a/a_00'$i''

I suspect there's more to this than you show.
 
Old 11-30-2007, 07:44 AM   #3
littletransformer
LQ Newbie
 
Registered: Nov 2007
Posts: 18

Original Poster
Rep: Reputation: 0
Question about the problem

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?
 
Old 11-30-2007, 08:20 AM   #4
enemorales
Member
 
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 31
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.
 
Old 11-30-2007, 06:16 PM   #5
littletransformer
LQ Newbie
 
Registered: Nov 2007
Posts: 18

Original Poster
Rep: Reputation: 0
Wink reply

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.
 
Old 11-30-2007, 06:19 PM   #6
littletransformer
LQ Newbie
 
Registered: Nov 2007
Posts: 18

Original Poster
Rep: Reputation: 0
Exclamation

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.
 
Old 12-01-2007, 06:35 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Please show us the code and explain what you mean by 'export the file'?
 
Old 12-01-2007, 10:28 PM   #8
littletransformer
LQ Newbie
 
Registered: Nov 2007
Posts: 18

Original Poster
Rep: Reputation: 0
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Assembly, "bash: ./exit: cannot execute binary file" User Name. Programming 4 08-07-2007 09:09 AM
[SOLVED] Installind Slamd64-current. "cannot execute binary file" message about installpkg BrutalMusic Slackware - Installation 1 05-11-2006 09:35 AM
"cannot execute binary file" when install j2sdk jin007 Linux - Software 3 06-27-2005 02:05 PM
SIN linux native - "cannot execute binary file" darkranger Linux - Games 1 06-07-2005 08:34 AM
"Cannot execute KDE: No such file or directory" abboq Linux - Software 1 09-27-2003 08:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration