Results 1 to 10 of 14
Hi friends,
I want to use perl program in my shell script,so I write "/perl/bin/perl.exe a.pl",but when I run it,it returns"/perl/bin/perl.exe: cannot execute binary file"
,I wonder why it comes ...
- 11-29-2007 #1Just Joined!
- Join Date
- Nov 2007
- Posts
- 7
why does it say"/perl/bin/perl.exe: cannot execute binary file"?
Hi friends,
I want to use perl program in my shell script,so I write "/perl/bin/perl.exe a.pl",but when I run it,it returns"/perl/bin/perl.exe: cannot execute binary file"
,I wonder why it comes that.
- 11-29-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539
.exe is a microsoft thingy

type
The output of that command should tell you where your shell is looking for the perl interpreter.Code:$ which perl
for example:
Code:[xxx@### ~]$ which perl /usr/bin/perl
RHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.
- 11-29-2007 #3
Welcome to the forums!
Shouldn't that have been /usr/bin/perl?
Originally Posted by littletransformer
I'm a bit confused by the path and the .exe suffix. The .exe suffix doesn't mean anything in Gnu/Linux, rather it is used by a different popular OS.
Originally Posted by littletransformer
Because of the error you get and the perl.exe thing, I'm inclined to think you've installed a Windows version on your machine?
You may want to enter: which perl
This gives the full path to the executable you'll need to run... if installed of course. But most Linux systems have
EDIT: matonb beat me to it
Can't tell an OS by it's GUI
- 11-29-2007 #4Just Joined!
- Join Date
- Nov 2007
- Posts
- 7
It works,thanks for your help.
I am a new user of linux, so I really appreciate your help.
but I now meet a new problem,that is I have the perl program in the shell script,which receive two filenames as parameters.
so I make it "/usr/bin/perl /perl/a.pl $afile $bfile",both of the two files just consist of some text and don't have any extension names,but it seems that the program doesn't receive the parameters ,besides,it returns
"afile:cannot execute binary file
bfile:cannot execute binary file ".
So I feel really confused about the problem.
- 11-29-2007 #5Linux User
- Join Date
- Jun 2007
- Posts
- 318
It would help if you post the shell script and /perl/a.pl.
- 11-30-2007 #6Just Joined!
- Join Date
- Nov 2007
- Posts
- 7
about the code
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
I am really grateful for your help.
- 11-30-2007 #7Linux User
- Join Date
- Jun 2007
- Posts
- 318
Which shell are you using? I'm assuming bash so I corrected the errors so it would run in bash:
Compare it to you original script and you'll see the changes I made.Code:#!/bin/bash i=1 pbfile="" tbfile="" while test $i -lt 1000 do if test $i -lt 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 ./a.pl $afile $bfile ((i=$i+1)) done
There's a problem with your perl script but I'm not familiar with perl.
- 11-30-2007 #8Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539
Or you coud just do the following:
Code:#!/bin/bash for i in $(seq -w 1 1 1000); do ./a.pl "/a/a_"$i "/b/b_"$i done;
RHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.
- 11-30-2007 #9Just Joined!
- Join Date
- Nov 2007
- Posts
- 7
to vsemaska
friend,thank you for your help.acutuallty I used bash to run the script, and with your help now it can almost work well ,but do you mean that I should define the value afile with" afile="/a/a_00$i" " without the '$' mark. I am really puzzled about it, how come it different from the usage of variable i.
at the same time now I have a small problem left, that is whenever I run it ,it will return 'error open bfile! no such file or directory',do you have any ideas about that?
besides,why do you think my perl program has some problems,can you make it a bit clear?
- 11-30-2007 #10Just Joined!
- Join Date
- Nov 2007
- Posts
- 7
another problem
now I think I get another problem when I try to export the output in my shell script,do you friends have any ideas how I can handle this?
I am thinking of changing "/usr/bin/perl ./a.pl $afile $bfile"
for "/usr/bin/perl ./a.pl $afile $bfile>>/output/output_$i",but it doesn't work.If I want to make the output in separate files,like a_1 and b_1's output to output_1,how can I manage it?
thank you!


Reply With Quote