Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: ulimit output?

by Fletch (Chancellor)
on Apr 01, 2008 at 21:25 UTC ( #677839=note: print w/ replies, xml ) Need Help??


in reply to ulimit output?

On some OSen the ulimit command is solely a shell builtin, not an external program. When you try and run it via backticks Perl is looking at your command and thinking it can cheat and run the command itself rather than invoking a shell (since it's a simple command with spaces as the only shell metacharacter). If your OS is one of those without a separate ulimit, what's really happening is that Perl tries to exec the non-existent program and fails (giving you back an undef, but you don't check for that).

The work around is to explicitly get the shell involved, either by putting some shell metacharacters in your command (qx/ulimit -n 3>&-/) or by invoking a shell explicitly (qx/bash -c "ulimit -n"/).

Update: Tweaked sample metacharacters in first example.

The cake is a lie.
The cake is a lie.
The cake is a lie.


Comment on Re: ulimit output?
Select or Download Code
Re^2: ulimit output?
by moklevat (Priest) on Apr 01, 2008 at 21:30 UTC

    Your first example doesn't work for me:

    perl -e 'print qx/ulimit -n 2>&1/;'

    prints nothing.

    Update: Well, you update faster than I complain. Your new first example is dandy! ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://677839]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (19)
As of 2014-07-11 16:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (232 votes), past polls