Re: Choosing the path based on the system "uname" command
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 27 Feb 2007 12:01:46 -0800
On Feb 27, 2:49 pm, "doni" <doni.se...@xxxxxxxxx> wrote:
Hi,
I want to write a program that does check the appropriate system path
for perl in FreeBSD and Linux.
The path where I have it in FreeBSD is
#! /usr/local/bin/perl
and the path where it is in Linux is
#! /usr/bin/perl
I wanted the program to check for the uname of the system and choose
the appropriate path. Can anyone tell me how can I have my program
check this.
This is how I wrote the program but it doesnt work.
#! /usr/local/bin/perl
use strict;
use warnings;
if (system("uname") eq "Linux") {
What do you think that does?
Please read the documentation for the function you're using
perldoc -f system
perldoc -q system
#! /usr/bin/perl
That's a comment, and nothing more. The #! syntax means nothing
unless it's the first two characters of the file.
You probably meant to do an exec()
perldoc -f exec
And to avoid an infinite loop, you'll need to make sure you're not
already executing the version you meant to. I think you'll need both
the $0 and $^X variables. You can read about them in:
perldoc perlvar
In fact, you could probably get rid of the call to uname entirely, by
using the $^0 variable, also documented in that perldoc.
Hope that helps,
Paul Lalli
.
- References:
- Prev by Date: Re: Disable warnings from specific module
- Next by Date: FAQ 7.19 Why doesn't "my($foo) = <FILE>;" work right?
- Previous by thread: Choosing the path based on the system "uname" command
- Next by thread: Re: Choosing the path based on the system "uname" command
- Index(es):
Relevant Pages
|