Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
go ahead... be a heretic
 
PerlMonks  

Re: system commands and returns

by JavaFan (Canon)
on Nov 30, 2011 at 00:12 UTC ( #940737=note: print w/ replies, xml ) Need Help??


in reply to system commands and returns

It doesn't "return" to the UNIX command prompt. I does exactly what you ask it to do: start up a *new* shell, as the user passed in as $_[0]. Typing exit causes this new shell to exit, which causes the system to terminate, which causes the next command to run.

If you want to run commands as the other user, pass them as an argument to su.


Comment on Re: system commands and returns
Select or Download Code
Re^2: system commands and returns
by perl_zen (Initiate) on Nov 30, 2011 at 14:40 UTC

    @JavaFan

    Thank you for this explanation. Being new to Perl, it is very helpful.

    I have several commands that I would like to execute as  other_user , so I would like that particular shell to execute more than one command. As in the sample code, I would like to su to the user and print "cOmMaNd LiNe" without any external interaction. Needing to type "exit" from the command line (in order to get "cOmMaNd LiNe" to print) prohibits this ability.

    I think your explanation and the example given by cdarke both look promising.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2014-04-21 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls