[Israel.pm] system() platform dependant issue
Gaal Yahas
gaal at forum2.org
Tue Sep 5 05:11:51 PDT 2006
On Tue, Sep 05, 2006 at 01:52:46PM +0300, Levenglick Dov-RM07994 wrote:
> This runs very nicely on Linux but returns "sh: /dev/null: bad number"
> on Solaris. Can anyone explain?
> Can anyone give me a robust solution that will run on all shells on all
> platforms?
>
> #!/usr/local/bin/perl
>
> $cmd = 'echo blaaaa >& /dev/null';
> system("$cmd");
'>&' is a cshism that made it into bash, which is what your /bin/sh
no doubt really is on linux. Solaris, which has an honest-to-god real
Bourne shell, doesn't know it.
Since Perl uses /bin/sh on all unixes, you may be able to get by with
the traditional
$cmd = 'echo blaaaaa > /dev/null 2>&1';
But this is not guaranteed to work on non-unix platforms.
--
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/
More information about the Perl
mailing list