Home > Enterprise >  How to execute the command in another bash prompt in Perl?
How to execute the command in another bash prompt in Perl?

Time:02-22

I am working on enter image description here

I have written the below script, but it is not working

$x = `cnvpytor -root s1.pytor -view 10000`;     #normal bash
$x = `set Q0_range -1 0.5`;                     # this and after this, enter into the cnvpytor
$x = `set p_range 0 0.0001`;
$x = `set p_N 0 0.5`;
$x = `set print_filename s1_output.vcf`;
$x = `set annotate`;
$x = `print calls`;
$x = `quit`;

CodePudding user response:

Each backtick pair runs a separate process.

I have no idea what CnvPytor is (and the link you provided doesn't help much), but the usual way is to run the external tool using some kind of IPC to communicate with it.

CodePudding user response:

If you don't need the output from the command, use:

open(PIPE, '|cnvpytor -root s1.pytor -view 10000');
print PIPE <<'EOF';
set Q0_range -1 0.5
set p_range 0 0.0001
set p_N 0 0.5
set print_filename s1_output.vcf
set annotate
print calls
quit
EOF
close(PIPE);

If you do need the output to the command, you would write your cnvpytor commands to a file and then do:

open(INPUT, 'cnvpytor -root s1.pytor -view <filename |');
while (<INPUT>) {
     # Do something with each line of output
}
close(INPUT);
unlink('filename');

Where "filename" is your temporary file with input.

  • Related