I have a vital script, but it works only under Windows. Having broken my head a little, I realized that the problem of interaction with the system, and everything collapses because of 2 lines. Can you help me fix them please ... I beg of you.

My script on the pearl is in the folder with the photo. Works fine. But there is a second script that lies in the same folder and executes script number 1.

Here is the script: smooth frame change in timelapse / slideshow video . As I understand it, the problem is in lines from # 35 to # 46.

my $cmd = "smooth.pl --fps $fps --start-image $start_img --final-image $final_img --progression $progression"; # To consume all available CPU cores without slowing down the system # meke each 8-th smooth.pl running in foreground # while other 7 smooth.pl scripts are running in background. # These lines needs to be rewritten to run under Linux. if ($i % $threads_num) { print BATCH "START /MIN /BELOWNORMAL CMD /C CALL $cmd\n" } else { print BATCH "$cmd\n" } 

I tried to execute the script without change. Result:

 composing batch file './smooth_all.bat'... done. 

Help me please. Very necessary.

  • Thank you for formatting - Vitaly Zaslavsky
  • You are very messy described the problem. What exactly is very necessary, run under linux? - Kirill Novgorodtsev
  • Yes, I am a linuksoid - Vitaly Zaslavsky

2 answers 2

Solution to the forehead, without any threads: replace the lines

 if ($i % $threads_num) { print BATCH "START /MIN /BELOWNORMAL CMD /C CALL $cmd\n" } else { print BATCH "$cmd\n" } 


 system $cmd; 
  • First, before smooth.pl in $ cmd you need to put perl . Secondly, it’s done here so that 7 commands are executed asynchronously. It would be so simple, I would not ask - Vitaly Zaslavsky
  • In this case, fork one by one: perldoc.perl.org/functions/fork.html - Kirill Novgorodtsev

In general, Perl has such an element as $ ^ O (the letter "O", not zero). This variable stores information about the system where the interpreter is running. So basically just doing:

 #!/usr/bin/perl -w if ($^O eq 'MSWin32') { Блок } else { Блок } 

Well, something like this .... This will make the script portable from one platform and another.