Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Perl Stops Processing
Really quick question.  In Perl, if I open a file in notepad
system( "notepad.exe $file" ) ;
Perl stops processes and will not continue until I close notpad.
How can I open the file, and have Perl continue running?


Report this thread to moderator Post Follow-up to this message
Old Post
Inthepickle
04-03-08 12:19 AM


Re: Perl Stops Processing
http://perldoc.perl.org/functions/system.html
... the parent process waits for the child process to complete.
The return value is the exit status of the program as returned by the wait c
all.

You want to first fork and run the command in its own thread.

http://perldoc.perl.org/functions/fork.html

$val = fork;
if ( not defined $val ) {
print "Fork failed"
} elsif ($val == 0) {
system('notepad.exe');
exit;
}
...

Report this thread to moderator Post Follow-up to this message
Old Post
Yitzle
04-03-08 12:19 AM


Re: Perl Stops Processing
inthepickle wrote:
>
> Really quick question.  In Perl, if I open a file in notepad
> system( "notepad.exe $file" ) ;
> Perl stops processes and will not continue until I close notpad.
> How can I open the file, and have Perl continue running?

Quick question, slow answer.

Perl will either spawn a shell subprocess and wait for it to complete
(using the system() call as you have described) or start a process and
exit (using a call to exec()).

You may want to take a look at calling fork(), but starting a process
from another process leaves the parent with a big responsibility, and
it's more likely that your Perl program should simply complete all that
it has to do and then

exec "notepad $file";

when it is about to terminate.

HTH,

Rob



Report this thread to moderator Post Follow-up to this message
Old Post
Rob Dixon
04-03-08 12:19 AM


Re: Perl Stops Processing
From: inthepickle <inthepickle@gmail.com>
> Really quick question.  In Perl, if I open a file in notepad
> system( "notepad.exe $file" ) ;
> Perl stops processes and will not continue until I close notpad.
> How can I open the file, and have Perl continue running?

system(1, 'notepad.exe', $file)

Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


Report this thread to moderator Post Follow-up to this message
Old Post
Jenda Krynicky
04-03-08 12:19 AM


Re: Perl Stops Processing
Jenda Krynicky wrote:
>
> From: inthepickle <inthepickle@gmail.com>
> 
>
> system(1, 'notepad.exe', $file)

Is that documented anywhere Jenda?

Rob

Report this thread to moderator Post Follow-up to this message
Old Post
Rob Dixon
04-03-08 12:19 AM


Re: Perl Stops Processing
From: Rob Dixon <rob.dixon@gmx.com>
> Jenda Krynicky wrote: 
>
> Is that documented anywhere Jenda?
>
> Rob

perldoc perlport

in the "Alphabetical Listing of Perl Functions" section under
"system".

Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


Report this thread to moderator Post Follow-up to this message
Old Post
Jenda Krynicky
04-03-08 01:11 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:55 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.