Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Keep It Simple, Stupid
 
PerlMonks  

Re: How to execute commands in the same shell as Perl script

by cdarke (Prior)
on Sep 13, 2011 at 12:21 UTC ( #925691=note: print w/ replies, xml ) Need Help??


in reply to How to execute commands in the same shell as Perl script

You seem to be confusing just what a shell is. A shell is just another program. So bash is a program that runs in a process, as is ksh, as is csh, as is ls, as is ps, as is perl, as is python, etc. Some shell commands are 'built-ins', like cd, and those do not require a separate process. Others that can be shell commands, which you might inaccurately call an "OS command", are programs like ls and ps which have nothing to do with a shell - it is just that we often invoke them from a shell.

You can't directly 'source' the ls or ps programs for example, they are binary (ELF) executables that run in a separate process. You can source the command to invoke them, but they will still run in a different process to your shell. The perl program is no different.

Fortunately there are Perl equivalents to many UNIX programs and utilities that you might call from a shell, see UNIX 'command' equivalents in Perl.


Comment on Re: How to execute commands in the same shell as Perl script

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-04-20 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (487 votes), past polls