Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: how to execute 'tmboot -y'

by haukex (Archbishop)
on Jul 25, 2017 at 18:34 UTC ( [id://1196036]=note: print w/replies, xml ) Need Help??


in reply to how to execute 'tmboot -y'

Each call to system spawns a new subprocess, each with its own environment, changes made to one won't affect the other. Also, you seem to be expecting system to return the output of the command, which it does not, it returns its exit code. If and only if the external command you want to run is always a fixed string, then one way to do what you want would be:

use IPC::System::Simple qw/capture/; my $output = capture('cd /server/setup && setenv.cmd && tmboot -y');

However, as I said, this is only a good idea for fixed strings, because otherwise you may introduce security issues! I wrote about the topic of running external commands at length here.

Update: Since I've added the cd to the command above, that change of working directory will not take effect for your script after the call returns. If you really want to change your working directory, then you should use Perl's chdir like you showed in your original code - perhaps just adding some error checking.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-20 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found