Backtick and path setting

G

gundalav

Hi all,

I have the following directory structure for storing my code and
one binary executable use by the Perl's code.

~/MyPerl
|
|
|__ src/
|_ mycode.pl
|
|_ a_program.out

Currently in mycode.pl, I have

__BEGIN__
use strict;
use warnings;

my @output = `./a_program.out -f someparam`; # line 217
chomp @output;

# Rest of the code
__END__

Although I have no problem running the following:

~/MyPerl $ perl -c src/mycode.pl
mycode.pl syntax OK

But I have problem when doing this:

~/MyPerl $ perl src/mycode.pl

It gives:

Can't exec "./a_program.out": No such file or directory at
src/mycode.pl line 217.

I've tried setting full path under backtick also but it still give the
same error.

What's wrong with my path setting under backtick? Did I miss anything?
 
B

Brian McCauley

Hi all,

I have the following directory structure for storing my code and
one binary executable use by the Perl's code.

~/MyPerl
|
|
|__ src/
|_ mycode.pl
|
|_ a_program.out

Currently in mycode.pl, I have

__BEGIN__
use strict;
use warnings;

my @output = `./a_program.out -f someparam`; # line 217
chomp @output;

# Rest of the code
__END__

Although I have no problem running the following:

~/MyPerl $ perl -c src/mycode.pl
mycode.pl syntax OK

But I have problem when doing this:

~/MyPerl $ perl src/mycode.pl

It gives:

Can't exec "./a_program.out": No such file or directory at
src/mycode.pl line 217.

Well, that is to be expected, you just told us that a_program.out is in
the src/ directory not in the current directory ~/MyPerl.
I've tried setting full path under backtick also but it still give the
same error.

That seems inprobable.

What exactly did the code look like? What exactly was the error?
What's wrong with my path setting under backtick? Did I miss anything?

Well, you've not shown us the code, but a random shot in the dark...
FAQ: "How can I translate tildes (~) in a filename?"
 
B

Brian McCauley

Brian said:
....a random shot in the dark...
FAQ: "How can I translate tildes (~) in a filename?"

Please disregard. Well I did say i was random.
 
T

tuser

Hi all,

I have the following directory structure for storing my code and
one binary executable use by the Perl's code.

~/MyPerl
|
|
|__ src/
|_ mycode.pl
|
|_ a_program.out

Currently in mycode.pl, I have

__BEGIN__
use strict;
use warnings;

my @output = `./a_program.out -f someparam`; # line 217
chomp @output;

# Rest of the code
__END__

Although I have no problem running the following:

~/MyPerl $ perl -c src/mycode.pl
mycode.pl syntax OK

But I have problem when doing this:

~/MyPerl $ perl src/mycode.pl

It gives:

Can't exec "./a_program.out": No such file or directory at
src/mycode.pl line 217.

That's because there is no "./a_program.out" in the directory where you
ran "mycode.pl" (and I assume that the directory is "~/MyPerl")

As I see it, the situation is as follows:
============================
"~/MyPerl/src/a_program.out" --> exists, but not used by "mycode.pl"
"~/MyPerl/a_program.out" --> does not exist, but used by "mycode.pl"

Maybe the following works:
======================
instead of: `./a_program.out -f someparam`,
you could try: `src/a_program.out -f someparam`;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top