good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: wrapping bash and astronomyby bliako (Monsignor) |
on Feb 28, 2023 at 19:10 UTC ( [id://11150654]=note: print w/replies, xml ) | Need Help?? |
#my $s1 = capturex 'set -eu'; # "set -eu" failed to start: "No such file or directory"
The usage is systemx("some_command",@args);. So: my $s1 = capturex 'set', '-eu'; The difference being that command and subsequent arguments must all be passed individually and not in one single string. The way you are calling it, it thinks that the whole string is one single command (and it complains it can't find it). HOWEVER! I assume that capturex, systemx and friends spawn a system command directly or via an ephemeral shell which ends as soon as the shell command ends. This means that a sequence of capturex calls will use completely different shells, which will not share any state. So, setting shell options via set -eu on one capturex call will not be preserved on the next capturex call. If you want to preserve state in a shell and execute many shell commands in it there is a simple way: first create a temporary shell script (see tempfile of File::Temp) within your perl-script to contain all the commands you want to run. And then execute this shell script via a single capturex call. Edit: Data::Dumper allows hiding the $VAR1 = section of its output if you set $Data::Dumper::Terse = 0; before first call. Similarly, perl2dump of Data::Roundtrip also allows terse output via perl2dump($vartodump, {'terse'=>1}); So you will have less text to filter out. Aldebaran++ I have to commend your efforts not only in using Perl but also in using Linux. It's a steep learning curve but it hides a ... springboard at the end of it. Plus the methodical approach you take in achieving your aims. bw, bliako
In Section
Seekers of Perl Wisdom
|
|