CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [dwaynepeeters] Restart/reload an impress from Perl: Edit Log



FishMonger
Veteran / Moderator

Apr 8, 2014, 6:23 AM


Views: 7141
Re: [dwaynepeeters] Restart/reload an impress from Perl

Why are you using 'cp' and 'pkill' system calls? Are you not aware that perl has the built-in kill function to kill a process and the File::Copy module to copy files?

The script is not "freezing". The system function forks a new (child) process to run the command and waits for that process to complete/exit before proceeding to the next statement.

If you want it to return immediately, you'll need to run libreoffice as a background process.

Code
system("libreoffice —quickstart -show —norestore /home/picuntu/Desktop/Presentation.odp &");


A better method to do that would be to use the Proc::Background module.

Code
use Proc::Background; 

my $cmd = "libreoffice —quickstart -show —norestore /home/picuntu/Desktop/Presentation.odp";
my $libreoffice = Proc::Background->new($cmd);


http://perldoc.perl.org/functions/kill.html
http://perldoc.perl.org/functions/unlink.html
http://search.cpan.org/~rjbs/perl-5.18.2/lib/File/Copy.pm
http://search.cpan.org/~bzajac/Proc-Background-1.10/lib/Proc/Background.pm


(This post was edited by FishMonger on Apr 8, 2014, 6:24 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Apr 8, 2014, 6:24 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives