Running system() commands in background

Q

qazmlp

Whenever system("command") is called in a perl script, a new
(commandline) window opens and shows the execution of the "command".
What do I need to do if
I have to run the command in the background? Basically, I do not
prefer the user to see what is happening when the perl script is being
executed.

The test was done in Win2K & the solution is required in the same.

Thanks!
 
H

Helgi Briem

Whenever system("command") is called in a perl script, a new
(commandline) window opens and shows the execution of the "command".
What do I need to do if
I have to run the command in the background? Basically, I do not
prefer the user to see what is happening when the perl script is being
executed.

The test was done in Win2K & the solution is required in the same.

Have a look at perldoc perlwin32

Specifically, you want to run your script using wperl.exe
instead of perl.exe.
 
A

Alan J. Flavell

Whenever system("command") is called in a perl script, a new
(commandline) window opens and shows the execution of the "command".
What do I need to do if
I have to run the command in the background?

What you need to do is to read the Windows-specific documentation for
whichever Windows port of Perl you are using.

AFAIR, in the case of ActiveState Perl, it tells you that you'd
execute wperl instead of perl. It worked for me (it's been a while,
which is why I'm suggesting you read the doc instead of just blindly
following anything I might say).
 
T

Trent Curry

qazmlp said:
Whenever system("command") is called in a perl script, a new
(commandline) window opens and shows the execution of the "command".
What do I need to do if
I have to run the command in the background? Basically, I do not
prefer the user to see what is happening when the perl script is being
executed.

The test was done in Win2K & the solution is required in the same.

Thanks!

Anyone know if this works in windows (it does under unix/linux):

<code type=perl;handtyped>
#!/usr/bin/perl -w

use strict;

exit if fork;

system("command");
</code>

I'm not sure fork will work under win32. Worth a try I suppose.

--
Trent Curry

perl -e
'($s=qq/e29716770256864702379602c6275605/)=~s!([0-9a-f]{2})!pack("h2",$1)!eg
;print(reverse("$s")."\n");'
 
T

Tintin

qazmlp said:
Whenever system("command") is called in a perl script, a new
(commandline) window opens and shows the execution of the "command".
What do I need to do if
I have to run the command in the background? Basically, I do not
prefer the user to see what is happening when the perl script is being
executed.

What is the command you are running? Base on your other post, it is likely
there is an Perl function.
 
M

Michele Dondi

What you need to do is to read the Windows-specific documentation for
whichever Windows port of Perl you are using.
Agreed!

AFAIR, in the case of ActiveState Perl, it tells you that you'd
execute wperl instead of perl. It worked for me (it's been a while,

This doesn't quite answer the OP's question. In fact AS's wperl
executes perl scripts without opening a new window, but new windows
are opened for each system().

Apart the correct suggestion above, a more generic one could be to use
either qx// or open(), one of which may be more appropriate for other
reasons too.


Michele
 
K

ko

qazmlp said:
Whenever system("command") is called in a perl script, a new
(commandline) window opens and shows the execution of the "command".
What do I need to do if
I have to run the command in the background? Basically, I do not
prefer the user to see what is happening when the perl script is being
executed.

The test was done in Win2K & the solution is required in the same.

Thanks!

As explained in the Win32 docs, you can 'hide' windows from system()
child process(es):

use Win32;
SetChildShowWindow();

HTH -keith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top