I'm trying to run a series of shell commands with Perl6 to the variable $cmd
, which look like
databricks jobs run-now --job-id 35 --notebook-params '{"directory": "s3://bucket", "output": "s3://bucket/extension", "sampleID_to_canonical_id_map": "s3://somefile.csv"}'
- Splitting the command by everything after
notebook-params
my $cmd0 = 'databricks jobs run-now --job-id 35 --notebook-params '; my $args = "'{\"directory\": \"$in-dir\", \"output\": \"$out-dir\", \"sampleID_to_canonical_id_map\": \"$map\"}'"; my $run = run $cmd0, $args, :err, :out;
Fails. No answer given either by Databricks or the shell. Stdout and stderr are empty.
Splitting the entire command by white space
my @cmd = $cmd.split(/\s+/); my $run = run $cmd, :err, :out
Error: Got unexpected extra arguments ("s3://bucket", "output": "s3://bucket/extension", "sampleID_to_canonical_id_map": "s3://somefile.csv"}'
- Submitting the command as a string my $cmd = "$cmd0\"$in-dir\", \"output\": \"$out-dir\", \"sampleID_to_canonical_id_map\": \"$map\"}'";
again, stdout and stderr are empty. Exit code 1.
this is something about how run
can only accept arrays, and not strings (I'm curious why)
If I copy and paste the command that was given to Perl6's run
, it works when given from the shell. It doesn't work when given through perl6. This isn't good, because I have to execute this command hundreds of times.
Perhaps Perl6's shell https://docs.perl6.org/routine/shell would be better? I didn't use that, because the manual suggests that run
is safer. I want to capture both stdout and stderr inside a Proc
class
EDIT: I've gotten this running with shell
but have encountered other problems not related to what I originally posted. I'm not sure if this qualifies as being answered then. I just decided to use backticks with perl5. Yes, backticks are deprecated, but they get the job done.