Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by cdarke (Prior)
on Sep 13, 2011 at 12:21 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://925691]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 15:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found