Re: Call Perl Scripts from Other Dir in Linux, Path Messed Up
From: Josef Möllers (josef.moellers_at_fujitsu-siemens.com)
Date: 10/29/03
- Next message: Steffen Kluge: "Re: bash question"
- Previous message: Public Interest: "Re: Call Perl Scripts from Other Dir in Linux, Path Messed Up"
- In reply to: Public Interest: "Re: Call Perl Scripts from Other Dir in Linux, Path Messed Up"
- Next in thread: Steve Grazzini: "Re: Call Perl Scripts from Other Dir in Linux, Path Messed Up"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 29 Oct 2003 09:03:00 +0100
Public Interest wrote:
>
> I followed your instruction as
> sh -x RUN.sh
> but except it prints something extra as
> + perl 111.pl
> + perl 222.pl
> , it is the same as sh RUN.sh
>
> I can run perl anywhere, so I think perl is in my path
>
> in my abc.pl file, I "open (INPUT "input.txt")", so if the input file sits
> right with the .pl file, and it works perfectly if I call from the same dir.
> but not from other dirs
That's what the notions of "current working directory" and "relative
path" do.
You either specify an absolute path or your specify a relative path and
the system sort-of prepends the current working directory.
> my file system:
>
> /perlfiles/111.pl
> /perlfiles/222.pl
> /perlfiles/333.pl
> /perlfiles/abc.pl
> /perlfiles/input.txt
> /perlfiles/RUN1.sh
> /RUN2.sh
>
> at /perlfiles/
> "sh RUN1.sh" OK
> "RUN1.sh" bash: RUN1.sh: command not found
> at /
> "sh /perlfiles/RUN1.sh" file input.txt not found in abc.pl
> "sh RUN2.sh" file input.txt not found in abc.pl
>
> What I think I can do is I CD to the path in RUN2.sh and run the script, and
> CD back to the default dir. But it seems other better ways to do it.
As for finding executables: add their absolute path(s) to the PATH
environment variable.
As for finding files: either put them into a well-known location (/lib,
/usr/lib, $HOME/lib, ...) or provide the absolute path of their location
into an environment variable (MY_DATAFILE_PATH=/perlfiles) or into a
configuration file ($HOME/.myperlconfig) or whatever, but the system is
pretty helpless in guessing where your files are.
-- Josef Möllers (Pinguinpfleger bei FSC) If failure had no penalty success would not be a prize -- T. Pratchett
- Next message: Steffen Kluge: "Re: bash question"
- Previous message: Public Interest: "Re: Call Perl Scripts from Other Dir in Linux, Path Messed Up"
- In reply to: Public Interest: "Re: Call Perl Scripts from Other Dir in Linux, Path Messed Up"
- Next in thread: Steve Grazzini: "Re: Call Perl Scripts from Other Dir in Linux, Path Messed Up"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|